74892024-01-09 10:34:15ffteklaSípálya (55 pont)cpp17Wrong answer 18/55474ms4584 KiB
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int i,j,K,N,koltseg,magassag,mini=INT_MAX;
vector <int>v;

int main()
{
    cin>>N;
    cout<<" ";
    cin>>K;
    v.resize(N+1);
    for (i=1;i<=N;++i)
        cin>>v[i];

    for (i=1;i<=N-K+1;++i)
    {
        koltseg=0;
        magassag=v[i+K-1];
        for(j=i+K-1;j>i;--j)
            if(v[j-1]<=magassag)
        {
            koltseg+=magassag-v[j-1]+1;
            magassag++;
        }
        else
        {
            koltseg+=(v[j-1]-magassag-1)*(i+K-j);
            magassag=v[j-1];
        }
        if(koltseg<mini) mini=koltseg;
    }
    cout<<mini;
}
SubtaskSumTestVerdictTimeMemory
base18/55
1Accepted0/03ms1876 KiB
2Accepted0/03ms2068 KiB
3Accepted2/23ms2280 KiB
4Accepted2/23ms2496 KiB
5Accepted2/24ms2708 KiB
6Accepted2/23ms2756 KiB
7Wrong answer0/33ms2844 KiB
8Accepted1/112ms3256 KiB
9Accepted1/113ms3176 KiB
10Accepted1/114ms3536 KiB
11Accepted1/121ms3420 KiB
12Accepted1/121ms3320 KiB
13Accepted1/143ms3392 KiB
14Accepted2/246ms3468 KiB
15Accepted2/221ms3416 KiB
16Time limit exceeded0/2474ms3568 KiB
17Time limit exceeded0/2449ms3596 KiB
18Time limit exceeded0/2469ms3808 KiB
19Time limit exceeded0/3460ms4196 KiB
20Time limit exceeded0/2462ms4092 KiB
21Time limit exceeded0/2467ms4104 KiB
22Time limit exceeded0/2453ms4380 KiB
23Time limit exceeded0/2472ms4444 KiB
24Time limit exceeded0/2465ms4388 KiB
25Time limit exceeded0/2453ms4460 KiB
26Time limit exceeded0/2469ms4456 KiB
27Time limit exceeded0/2462ms4520 KiB
28Time limit exceeded0/3465ms4444 KiB
29Time limit exceeded0/3453ms4448 KiB
30Time limit exceeded0/3474ms4584 KiB