141532025-01-10 07:38:19BravoSípálya (55 pont)cpp17Wrong answer 0/55500ms3508 KiB
#include <iostream>
#include <climits>
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int b[n];
    for(int i=0;i<n;i++){
        b[i]=0;
    }
    long long c=1000000000,o=0;
    for(int i=0;i<n;i++){
        while(a[i]!=c){
            a[i]++;
            o++;
        }
        c--;
        b[i]=o;
        o=0;
    }
    c=INT_MAX;
    for(int i=0;i<n;i++){
        if(b[i]<c){
            c=b[i];
        }
    }
    for(int i=0;i<n;i++){
        b[i]=b[i]-c;
    }
    for(int i=0;i<n;i++){
        a[i]=a[i]-c;
    }
    int e=INT_MAX;
    for(int i=0;i<n;i++){
        if(b[i]<e){
            e=b[i];
        }
    }
    for(int i=0;i<n;i++){
        cout << b[i] << " ";
    }
    c=INT_MAX;
    o=0;
    for(int i=0;i<n;i++){
        for(int j=i;j<i+k;j++){
            o=o+a[j];
        }
        o=o-k*e;
        if(o<c){
            c=o;
        }
        o=0;
    }
   cout << c;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/22ms316 KiB
4Wrong answer0/22ms316 KiB
5Wrong answer0/22ms316 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/32ms368 KiB
8Wrong answer0/18ms500 KiB
9Wrong answer0/18ms316 KiB
10Wrong answer0/19ms608 KiB
11Wrong answer0/112ms316 KiB
12Wrong answer0/112ms520 KiB
13Runtime error0/124ms536 KiB
14Runtime error0/228ms544 KiB
15Wrong answer0/212ms316 KiB
16Time limit exceeded0/2499ms3344 KiB
17Time limit exceeded0/2500ms3124 KiB
18Time limit exceeded0/2481ms3296 KiB
19Time limit exceeded0/3500ms3124 KiB
20Time limit exceeded0/2490ms3124 KiB
21Time limit exceeded0/2483ms3124 KiB
22Time limit exceeded0/2483ms3348 KiB
23Time limit exceeded0/2500ms3164 KiB
24Time limit exceeded0/2481ms3508 KiB
25Time limit exceeded0/2500ms3116 KiB
26Time limit exceeded0/2483ms3148 KiB
27Time limit exceeded0/2500ms3244 KiB
28Time limit exceeded0/3481ms3120 KiB
29Time limit exceeded0/3500ms3348 KiB
30Time limit exceeded0/3470ms3132 KiB