46582023-03-30 14:39:44AGergoSípálya (55 pont)cpp17Wrong answer 18/55476ms4748 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int szam,hosz;
    cin >> szam >> hosz;

    vector<int> hegyseg(szam);
    for(int i = 0; i < szam;i++)
    {
        cin >> hegyseg[i];
    }
    int cost = 2147483646; //int limit
    int 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
base18/55
1Accepted0/03ms1696 KiB
2Accepted0/03ms1932 KiB
3Accepted2/23ms2152 KiB
4Accepted2/23ms2236 KiB
5Accepted2/23ms2384 KiB
6Accepted2/23ms2604 KiB
7Wrong answer0/33ms2720 KiB
8Accepted1/18ms2820 KiB
9Accepted1/18ms2828 KiB
10Accepted1/19ms2828 KiB
11Accepted1/114ms2984 KiB
12Accepted1/113ms3160 KiB
13Accepted1/127ms3128 KiB
14Accepted2/230ms3124 KiB
15Accepted2/214ms3372 KiB
16Time limit exceeded0/2462ms3488 KiB
17Time limit exceeded0/2444ms3836 KiB
18Time limit exceeded0/2456ms4216 KiB
19Time limit exceeded0/3467ms4492 KiB
20Time limit exceeded0/2451ms4056 KiB
21Time limit exceeded0/2435ms3880 KiB
22Time limit exceeded0/2456ms4064 KiB
23Time limit exceeded0/2467ms4332 KiB
24Time limit exceeded0/2448ms4428 KiB
25Time limit exceeded0/2460ms4560 KiB
26Time limit exceeded0/2460ms4656 KiB
27Time limit exceeded0/2472ms4668 KiB
28Time limit exceeded0/3460ms4748 KiB
29Time limit exceeded0/3476ms4664 KiB
30Time limit exceeded0/3467ms4660 KiB