236702026-01-27 08:48:52AkosVagyokEmborSípálya (55 pont)cpp17Wrong answer 10/55500ms2804 KiB
#include <bits/stdc++.h>
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+=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/01ms500 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/22ms408 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/32ms508 KiB
8Wrong answer0/112ms516 KiB
9Wrong answer0/114ms512 KiB
10Wrong answer0/116ms520 KiB
11Accepted1/123ms520 KiB
12Accepted1/121ms516 KiB
13Wrong answer0/148ms544 KiB
14Wrong answer0/254ms512 KiB
15Accepted2/223ms516 KiB
16Time limit exceeded0/2500ms2716 KiB
17Time limit exceeded0/2486ms2612 KiB
18Time limit exceeded0/2499ms2612 KiB
19Time limit exceeded0/3500ms2612 KiB
20Time limit exceeded0/2488ms2612 KiB
21Time limit exceeded0/2500ms2612 KiB
22Time limit exceeded0/2486ms2804 KiB
23Time limit exceeded0/2486ms2612 KiB
24Time limit exceeded0/2486ms2612 KiB
25Time limit exceeded0/2500ms2612 KiB
26Time limit exceeded0/2485ms2612 KiB
27Time limit exceeded0/2486ms2612 KiB
28Time limit exceeded0/3486ms2612 KiB
29Time limit exceeded0/3500ms2612 KiB
30Time limit exceeded0/3486ms2612 KiB