46552023-03-30 14:37:42AGergoSípálya (55 pont)cpp17Wrong answer 18/55500ms4308 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    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/03ms1684 KiB
2Accepted0/03ms1848 KiB
3Accepted2/23ms2064 KiB
4Accepted2/23ms2308 KiB
5Accepted2/23ms2516 KiB
6Accepted2/23ms2572 KiB
7Wrong answer0/33ms2576 KiB
8Accepted1/19ms2732 KiB
9Accepted1/110ms3068 KiB
10Accepted1/112ms3140 KiB
11Accepted1/116ms3012 KiB
12Accepted1/114ms3008 KiB
13Accepted1/129ms3280 KiB
14Accepted2/232ms3496 KiB
15Accepted2/216ms3840 KiB
16Time limit exceeded0/2500ms3780 KiB
17Time limit exceeded0/2462ms4144 KiB
18Time limit exceeded0/2474ms4080 KiB
19Time limit exceeded0/3474ms4308 KiB
20Time limit exceeded0/2463ms3808 KiB
21Time limit exceeded0/2456ms3660 KiB
22Time limit exceeded0/2458ms3664 KiB
23Time limit exceeded0/2467ms3676 KiB
24Time limit exceeded0/2467ms3940 KiB
25Time limit exceeded0/2467ms4152 KiB
26Time limit exceeded0/2458ms4024 KiB
27Time limit exceeded0/2439ms3936 KiB
28Time limit exceeded0/3476ms4004 KiB
29Time limit exceeded0/3460ms4244 KiB
30Time limit exceeded0/3439ms4112 KiB