/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 14ms 492.0 KiB
#3 Wrong Answer 23ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(a) cout << #a << "-->" << (a) << '\n';

int main()
{
    ios ::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        vector<int> v(n);
        for (int i = 0; i < n; i++)
        {
            cin >> v[i];
        }
        ll sum = INT_MAX;
        for (int i = 0; i < n - 2; i++)
        {
            int j = i;
            int times = 0;
            ll ans = 0;
            while (times < k)
            {
                ans += v[j];
                j++;
                times++;
                if (times  == k)
                {
                    sum = min(ans, sum);
                    int u = j - 1;
                    ans -= v[u];
                    ans += v[j];
                    sum = min(ans, sum);
                }
               
            }
        }
        cout << sum << '\n';
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1149 Swap and Minimize
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 08:17:23
Judged At
2024-12-09 08:17:23
Judged By
Score
1
Total Time
23ms
Peak Memory
540.0 KiB