84362024-01-16 09:48:21GervidLeggyorsabb pénzkeresés (50)cpp17Wrong answer 4/5034ms14004 KiB
#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

int main()
{
    int n, p, i, j;
    cin >> n >> p;

    vector<int> days(n);
    
    for (i = 0; i < n; i++)
    {
        cin >> days[i];
    }

    int current = days[0], min = INT_MAX, out = 0;
    i = 0, j = 0;

    while (j < n)
    {
        while (current >= p)
        {
            current -= days[i];
            i++;
        
            if (min > current && current >= p && j < n)
            {
                min = current;
                out = j - i + 1;
            }
        }

        while (current < p)
        {
            j++;

            if (j >= n)
            {
                break;
            }

            current += days[j];
        }

    }

    cout << out;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/03ms1812 KiB
2Wrong answer0/032ms3276 KiB
3Accepted2/23ms2752 KiB
4Accepted2/23ms2988 KiB
5Wrong answer0/23ms3132 KiB
6Wrong answer0/26ms3260 KiB
7Wrong answer0/26ms3588 KiB
8Wrong answer0/26ms3596 KiB
9Wrong answer0/26ms3916 KiB
10Wrong answer0/26ms3940 KiB
11Wrong answer0/232ms5036 KiB
12Wrong answer0/232ms5772 KiB
13Wrong answer0/232ms6228 KiB
14Wrong answer0/232ms6840 KiB
15Wrong answer0/234ms7440 KiB
16Wrong answer0/232ms7892 KiB
17Wrong answer0/232ms8628 KiB
18Wrong answer0/232ms9112 KiB
19Wrong answer0/232ms9564 KiB
20Wrong answer0/232ms10420 KiB
21Wrong answer0/232ms10752 KiB
22Wrong answer0/232ms11356 KiB
23Wrong answer0/232ms11724 KiB
24Wrong answer0/232ms12336 KiB
25Wrong answer0/232ms12816 KiB
26Wrong answer0/232ms13548 KiB
27Wrong answer0/232ms14004 KiB