48312023-03-31 13:09:33csaron71Leggyorsabb pénzkeresés (50)cpp17Wrong answer 48/5032ms5960 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
base48/50
1Accepted0/03ms1808 KiB
2Accepted0/030ms3416 KiB
3Accepted2/23ms2272 KiB
4Accepted2/23ms2516 KiB
5Accepted2/23ms2640 KiB
6Accepted2/24ms2800 KiB
7Accepted2/24ms3096 KiB
8Accepted2/24ms3156 KiB
9Accepted2/24ms3268 KiB
10Accepted2/24ms3228 KiB
11Accepted2/230ms4508 KiB
12Accepted2/230ms4628 KiB
13Accepted2/230ms4844 KiB
14Accepted2/230ms4936 KiB
15Accepted2/230ms4948 KiB
16Accepted2/230ms5156 KiB
17Accepted2/230ms5240 KiB
18Accepted2/232ms5364 KiB
19Accepted2/230ms5456 KiB
20Accepted2/230ms5460 KiB
21Accepted2/230ms5528 KiB
22Accepted2/232ms5660 KiB
23Accepted2/230ms5744 KiB
24Wrong answer0/230ms5880 KiB
25Accepted2/230ms5876 KiB
26Accepted2/230ms5960 KiB
27Accepted2/230ms5956 KiB