152392025-02-17 13:59:06MrkzSípálya (55 pont)cpp17Wrong answer 0/55500ms1332 KiB
#include <iostream>

using namespace std;

int main()
{
    int N,K,megoldas=0;
    cin>>N>>K;
    int Csucs[N],Kezdo,ossz[N],maxi=0;
    for(int i=1;i<=N;i++){
        cin>>Csucs[i];

    }
    for(int i=1;i<=N-K+1;i++){
        for(int j=i;j<=i+K-1;j++){
            ossz[i]+=Csucs[j];
        }
        if(maxi<ossz[i]){
            maxi=ossz[i];
            Kezdo=i;
        }
    }
    for(int i=Kezdo+1;i<Kezdo+K;i++){
        if(Csucs[Kezdo]<=Csucs[i]){
            megoldas+=Csucs[i]-Csucs[Kezdo]+1;
            Csucs[Kezdo]=Csucs[i]+1;
        }
        if(Csucs[i]+1<Csucs[i-1]){
            megoldas+=Csucs[i-1]-Csucs[i]-1;
            Csucs[i]=Csucs[i-1]-1;
        }
    }

    cout<<megoldas;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/32ms316 KiB
8Wrong answer0/17ms316 KiB
9Wrong answer0/17ms544 KiB
10Wrong answer0/18ms444 KiB
11Wrong answer0/19ms316 KiB
12Wrong answer0/18ms316 KiB
13Runtime error0/117ms500 KiB
14Runtime error0/218ms508 KiB
15Wrong answer0/29ms468 KiB
16Time limit exceeded0/2500ms1292 KiB
17Time limit exceeded0/2500ms1060 KiB
18Time limit exceeded0/2486ms1124 KiB
19Time limit exceeded0/3500ms1076 KiB
20Time limit exceeded0/2493ms1076 KiB
21Time limit exceeded0/2500ms1332 KiB
22Time limit exceeded0/2483ms1244 KiB
23Time limit exceeded0/2500ms1332 KiB
24Time limit exceeded0/2483ms1236 KiB
25Time limit exceeded0/2500ms1076 KiB
26Time limit exceeded0/2483ms1268 KiB
27Time limit exceeded0/2500ms1204 KiB
28Time limit exceeded0/3481ms1092 KiB
29Time limit exceeded0/3500ms1196 KiB
30Time limit exceeded0/3481ms1076 KiB