219482026-01-14 11:03:32sklausSípálya (55 pont)cpp17Wrong answer 0/5579ms1152 KiB
#include <iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k; int t[n]; for(int i=0; i<n; i++)cin>>t[i];
    long long maxi=t[0],p,s=0;
    for(int i=0; i<k; i++){
        s+=(t[i]+i);
        if(t[i]+i>=maxi){p=i; maxi=t[i]+i;}}
    long long ar=k*maxi-s;
    for(int i=1; i<n-k+1; i++){

        if(i==p+1){
            maxi=t[i];
            for(int j=0; j<k; j++){
                if(t[i+j]+j>=maxi){p=i+j; maxi=t[i+j]+j;}}}
        else if(t[i+k]>=maxi){maxi=t[i+k]; p=i+k;}
        s=s-t[i]+t[i+k];
        ar=min(ar, k*maxi-s);}
    cout<<ar;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/01ms508 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/22ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/14ms316 KiB
9Wrong answer0/14ms316 KiB
10Wrong answer0/14ms316 KiB
11Wrong answer0/14ms316 KiB
12Wrong answer0/14ms316 KiB
13Wrong answer0/14ms352 KiB
14Wrong answer0/24ms316 KiB
15Wrong answer0/24ms384 KiB
16Wrong answer0/271ms964 KiB
17Wrong answer0/271ms1152 KiB
18Wrong answer0/271ms1076 KiB
19Wrong answer0/371ms1112 KiB
20Wrong answer0/272ms1076 KiB
21Wrong answer0/271ms964 KiB
22Wrong answer0/272ms1064 KiB
23Wrong answer0/274ms1060 KiB
24Wrong answer0/279ms1072 KiB
25Wrong answer0/274ms980 KiB
26Wrong answer0/272ms1076 KiB
27Wrong answer0/272ms1080 KiB
28Wrong answer0/372ms980 KiB
29Wrong answer0/372ms1076 KiB
30Wrong answer0/372ms1076 KiB