236952026-01-27 17:53:54AkosVagyokEmborSípálya (55 pont)cpp17Wrong answer 10/55500ms2804 KiB
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector <int> t, aLenyeg, os;
int n, k;
void be() {
    cin >> n >> k;
    t.resize(n + 1);
    os.resize(n + 1);
    aLenyeg.resize(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
        aLenyeg[i] = 0;
    }
}
void nagy() {
    for (int i = k; i <= n; i++) {
        int sum = 0;
        int maxx = t[i];
        int index = i;
        for (int j = i - 1; j >= i - k + 1; j--) {
            if (maxx <= t[j]) {
                maxx = t[j];
                index = j;
            }
        }
        for (int j = i; j >= i - k + 1; j--) {
            sum += abs(maxx - t[j] - (j - index));
        }
        aLenyeg[i] = sum;
    }

}

int main()
{
    be();
    nagy();
    int maxx = t[k];
    for (int i = k; i <= n; i++) {
        if (maxx > aLenyeg[i]) {
            maxx = aLenyeg[i];
        }
    }
    cout << maxx;
}
SubtaskSumTestVerdictTimeMemory
base10/55
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/22ms316 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/32ms316 KiB
8Wrong answer0/113ms512 KiB
9Wrong answer0/114ms508 KiB
10Wrong answer0/117ms512 KiB
11Accepted1/124ms516 KiB
12Accepted1/123ms508 KiB
13Wrong answer0/150ms508 KiB
14Wrong answer0/257ms508 KiB
15Accepted2/224ms520 KiB
16Time limit exceeded0/2500ms2612 KiB
17Time limit exceeded0/2477ms2612 KiB
18Time limit exceeded0/2499ms2612 KiB
19Time limit exceeded0/3500ms2612 KiB
20Time limit exceeded0/2488ms2804 KiB
21Time limit exceeded0/2500ms2612 KiB
22Time limit exceeded0/2479ms2612 KiB
23Time limit exceeded0/2481ms2612 KiB
24Time limit exceeded0/2479ms2616 KiB
25Time limit exceeded0/2500ms2616 KiB
26Time limit exceeded0/2485ms2796 KiB
27Time limit exceeded0/2486ms2568 KiB
28Time limit exceeded0/3477ms2612 KiB
29Time limit exceeded0/3500ms2612 KiB
30Time limit exceeded0/3483ms2612 KiB