76732024-01-10 12:13:37gyjazminSípálya (55 pont)cpp17Wrong answer 1/5589ms10264 KiB

#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);    
    int mx = 0;
    int mxh = 0;
    vector<int> hozzaadott(n);
    cin >> h[0];
    hozzaadott[0] = h[0];
    for (int i = 1;i < n;i++) {
        cin >> h[i];
        hozzaadott[i] = hozzaadott[i - 1] + h[i];
        if (h[i] > mx) {
            mx = h[i];
            mxh = i;
        }
    }
    vector<int> opt(n);
    vector<int> kiegyh(n);
    opt[0] = mx + mxh;
    kiegyh[0] = opt[0];
    for (int i = 1;i < n;i++) {
        opt[i] = opt[i - 1] - 1;
        kiegyh[i] = kiegyh[i - 1] + opt[i];
    }
    int legk =kiegyh[k-1]-hozzaadott[k-1];
    for (int i = 1;i < n-k;i++) {
        legk = min(legk, (kiegyh[i + k-1] - kiegyh[i - 1])-(hozzaadott[i+k-1]-hozzaadott[i-1]));
    }
    cout << legk << endl;
}
SubtaskSumTestVerdictTimeMemory
base1/55
1Accepted0/03ms1808 KiB
2Wrong answer0/03ms2060 KiB
3Wrong answer0/23ms2512 KiB
4Wrong answer0/23ms2464 KiB
5Wrong answer0/23ms2472 KiB
6Wrong answer0/23ms2856 KiB
7Wrong answer0/33ms3112 KiB
8Wrong answer0/16ms3444 KiB
9Wrong answer0/16ms3500 KiB
10Wrong answer0/16ms3732 KiB
11Wrong answer0/16ms3584 KiB
12Wrong answer0/16ms3588 KiB
13Accepted1/16ms3656 KiB
14Wrong answer0/26ms3648 KiB
15Wrong answer0/26ms3648 KiB
16Wrong answer0/282ms9620 KiB
17Wrong answer0/281ms9800 KiB
18Wrong answer0/281ms9756 KiB
19Wrong answer0/382ms10012 KiB
20Wrong answer0/282ms10092 KiB
21Wrong answer0/281ms10032 KiB
22Wrong answer0/281ms10032 KiB
23Wrong answer0/282ms10176 KiB
24Wrong answer0/289ms10208 KiB
25Wrong answer0/282ms10176 KiB
26Wrong answer0/282ms10028 KiB
27Wrong answer0/282ms10028 KiB
28Wrong answer0/381ms10032 KiB
29Wrong answer0/381ms10180 KiB
30Wrong answer0/382ms10264 KiB