236572026-01-27 08:23:42gyarturSípálya (55 pont)cpp17Wrong answer 0/55500ms1268 KiB
#include <iostream>
#include <vector>

using namespace std;

vector<int> x;
int n, k;

void Beolvas(){
    cin>>n>>k;
    x.resize(n);
    for(int i = 0; i < n; i++){
        cin>>x[i];
    }
}

int main()
{
    Beolvas();

    int mini = (1<<30);
    for(int i = 0; i < n-k; i++){
        int s = 0;
        for(int j = i+1; j < i+k; j++){
            int d = x[j] - x[j-1];
            if(d < 0){
                s += -1*d - 1;
            }
            else{
                s += (d+1)*(j-i);
            }
        }
        mini = min(s, mini);
    }
    cout<<mini;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms504 KiB
4Wrong answer0/22ms316 KiB
5Wrong answer0/22ms316 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/32ms404 KiB
8Wrong answer0/117ms316 KiB
9Wrong answer0/123ms508 KiB
10Wrong answer0/128ms432 KiB
11Wrong answer0/116ms436 KiB
12Wrong answer0/116ms432 KiB
13Wrong answer0/132ms432 KiB
14Wrong answer0/235ms432 KiB
15Wrong answer0/216ms432 KiB
16Time limit exceeded0/2500ms996 KiB
17Time limit exceeded0/2500ms1080 KiB
18Time limit exceeded0/2500ms1268 KiB
19Time limit exceeded0/3500ms1268 KiB
20Time limit exceeded0/2486ms1076 KiB
21Time limit exceeded0/2500ms1076 KiB
22Time limit exceeded0/2499ms1076 KiB
23Time limit exceeded0/2500ms1076 KiB
24Time limit exceeded0/2486ms1076 KiB
25Time limit exceeded0/2500ms1076 KiB
26Time limit exceeded0/2500ms1076 KiB
27Time limit exceeded0/2500ms1076 KiB
28Time limit exceeded0/3476ms1076 KiB
29Time limit exceeded0/3500ms1076 KiB
30Time limit exceeded0/3500ms1076 KiB