46832023-03-31 08:51:02AGergoSípálya (55 pont)cpp17Time limit exceeded 21/55500ms4488 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define speed ios::sync_with_stdio(0); cin.tie(0);

int main()
{
    speed;
    int szam,hosz;
    cin >> szam >> hosz;

    vector<int> hegyseg(szam);
    for(int i = 0; i < szam;i++)
    {
        cin >> hegyseg[i];
    }
    ll cost = LLONG_MAX; //long long limit
    ll maxi, sum;
    vector<int> num(hosz);
    for(int i = 0;i < szam - hosz + 1; i++)
    {
        maxi = 0;
        sum = 0;
        for(int j = 0; j < hosz; j++)
        {
            num[j] = hegyseg[i + j] + j;
            if (num[j] > maxi)
            {
                maxi = num[j];
            }
            sum += num[j];
        }
        if(maxi*hosz - sum < cost)
        {
            cost = maxi * hosz - sum;
        }
    }
    cout << cost;
}
SubtaskSumTestVerdictTimeMemory
base21/55
1Accepted0/03ms1828 KiB
2Accepted0/03ms2196 KiB
3Accepted2/23ms2248 KiB
4Accepted2/23ms2608 KiB
5Accepted2/23ms2572 KiB
6Accepted2/23ms2676 KiB
7Accepted3/33ms2892 KiB
8Accepted1/18ms3008 KiB
9Accepted1/19ms3136 KiB
10Accepted1/110ms3188 KiB
11Accepted1/114ms3156 KiB
12Accepted1/114ms3408 KiB
13Accepted1/130ms3532 KiB
14Accepted2/234ms3640 KiB
15Accepted2/214ms3576 KiB
16Time limit exceeded0/2500ms3680 KiB
17Time limit exceeded0/2467ms4076 KiB
18Time limit exceeded0/2456ms4088 KiB
19Time limit exceeded0/3483ms4368 KiB
20Time limit exceeded0/2474ms3824 KiB
21Time limit exceeded0/2472ms3820 KiB
22Time limit exceeded0/2472ms3836 KiB
23Time limit exceeded0/2451ms3784 KiB
24Time limit exceeded0/2439ms3692 KiB
25Time limit exceeded0/2437ms3704 KiB
26Time limit exceeded0/2456ms3892 KiB
27Time limit exceeded0/2453ms3956 KiB
28Time limit exceeded0/3451ms4228 KiB
29Time limit exceeded0/3416ms4488 KiB
30Time limit exceeded0/3451ms4380 KiB