84372024-01-16 09:51:11GervidLeggyorsabb pénzkeresés (50)cpp17Wrong answer 46/5034ms4900 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], out = INT_MAX;
    i = 0, j = 0;

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

        while (current < p)
        {
            j++;

            if (j >= n)
            {
                break;
            }

            current += days[j];
        }

    }

    cout << out;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/03ms1956 KiB
2Accepted0/034ms2896 KiB
3Accepted2/23ms2224 KiB
4Accepted2/23ms2356 KiB
5Wrong answer0/23ms2396 KiB
6Accepted2/26ms2816 KiB
7Accepted2/26ms2904 KiB
8Accepted2/26ms3124 KiB
9Accepted2/26ms3220 KiB
10Accepted2/26ms3080 KiB
11Accepted2/234ms3744 KiB
12Accepted2/234ms3872 KiB
13Accepted2/234ms4084 KiB
14Accepted2/234ms4332 KiB
15Accepted2/234ms4220 KiB
16Accepted2/234ms4072 KiB
17Accepted2/234ms4168 KiB
18Accepted2/234ms4200 KiB
19Accepted2/234ms4168 KiB
20Accepted2/234ms4168 KiB
21Accepted2/234ms4260 KiB
22Accepted2/234ms4492 KiB
23Wrong answer0/234ms4616 KiB
24Accepted2/234ms4696 KiB
25Accepted2/234ms4812 KiB
26Accepted2/234ms4900 KiB
27Accepted2/234ms4800 KiB