48282023-03-31 13:03:02csaron71Leggyorsabb pénzkeresés (50)cpp17Wrong answer 46/5032ms6096 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n, p;
    cin >> n >> p;
    vector<long long> v(n);
    for (long long i=0; i<n; i++) {
        cin >> v[i];
    }

    long long epp=0;
    long long mini=n;
    long long x=0, y=0;

    while (y<n) {
        if (epp<p) {
            y++;
            epp+=v[y];
        }
        else {
            mini=min(mini, y-x);
            x++;
            epp-=v[x];
        }
    }

    cout << mini << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/03ms1816 KiB
2Accepted0/030ms3408 KiB
3Accepted2/23ms2224 KiB
4Accepted2/23ms2332 KiB
5Wrong answer0/22ms2396 KiB
6Accepted2/24ms2848 KiB
7Accepted2/24ms3148 KiB
8Accepted2/24ms3244 KiB
9Accepted2/26ms3196 KiB
10Accepted2/26ms3448 KiB
11Accepted2/230ms4884 KiB
12Accepted2/230ms4968 KiB
13Accepted2/230ms4940 KiB
14Accepted2/232ms5072 KiB
15Accepted2/230ms5284 KiB
16Accepted2/230ms5368 KiB
17Accepted2/230ms5364 KiB
18Accepted2/230ms5496 KiB
19Accepted2/232ms5592 KiB
20Accepted2/232ms5812 KiB
21Accepted2/230ms5664 KiB
22Accepted2/232ms5664 KiB
23Wrong answer0/230ms5660 KiB
24Accepted2/230ms5900 KiB
25Accepted2/232ms6096 KiB
26Accepted2/230ms5972 KiB
27Accepted2/230ms6060 KiB