48292023-03-31 13:04:12csaron71Leggyorsabb pénzkeresés (50)cpp17Wrong answer 28/5032ms6228 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);
            epp-=v[x];
            x++;
        }
    }

    cout << mini << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/03ms1812 KiB
2Wrong answer0/030ms3412 KiB
3Accepted2/23ms2268 KiB
4Wrong answer0/23ms2484 KiB
5Wrong answer0/22ms2572 KiB
6Accepted2/24ms2892 KiB
7Wrong answer0/24ms3112 KiB
8Wrong answer0/26ms3324 KiB
9Wrong answer0/24ms3564 KiB
10Accepted2/24ms3516 KiB
11Wrong answer0/230ms4796 KiB
12Accepted2/232ms4840 KiB
13Accepted2/230ms4928 KiB
14Accepted2/230ms4924 KiB
15Wrong answer0/230ms4928 KiB
16Accepted2/230ms5188 KiB
17Accepted2/232ms5176 KiB
18Accepted2/230ms5276 KiB
19Accepted2/232ms5380 KiB
20Wrong answer0/232ms5600 KiB
21Accepted2/230ms5688 KiB
22Wrong answer0/232ms5660 KiB
23Wrong answer0/230ms5660 KiB
24Wrong answer0/230ms5876 KiB
25Accepted2/230ms5996 KiB
26Accepted2/230ms6228 KiB
27Accepted2/230ms6080 KiB