48332023-03-31 13:10:16csaron71Leggyorsabb pénzkeresés (50)cpp17Accepted 50/5032ms5572 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) {
            mini=min(mini, y-x);
            epp-=v[x];
            x++;
        }
        else {
            epp+=v[y];
            y++;
        }
    }

    cout << mini << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1684 KiB
2Accepted0/030ms3284 KiB
3Accepted2/23ms2144 KiB
4Accepted2/23ms2272 KiB
5Accepted2/23ms2488 KiB
6Accepted2/24ms2640 KiB
7Accepted2/24ms2692 KiB
8Accepted2/24ms2688 KiB
9Accepted2/26ms2936 KiB
10Accepted2/24ms3108 KiB
11Accepted2/230ms4428 KiB
12Accepted2/230ms4648 KiB
13Accepted2/230ms4620 KiB
14Accepted2/232ms4772 KiB
15Accepted2/230ms4824 KiB
16Accepted2/230ms5184 KiB
17Accepted2/230ms5096 KiB
18Accepted2/230ms5100 KiB
19Accepted2/230ms5072 KiB
20Accepted2/230ms5284 KiB
21Accepted2/230ms5328 KiB
22Accepted2/230ms5336 KiB
23Accepted2/230ms5572 KiB
24Accepted2/230ms5532 KiB
25Accepted2/230ms5336 KiB
26Accepted2/230ms5332 KiB
27Accepted2/230ms5332 KiB