48302023-03-31 13:06:20csaron71Leggyorsabb pénzkeresés (50)cpp17Wrong answer 12/5032ms6068 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+1);
            epp-=v[x];
            x++;
        }
    }

    cout << mini << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Wrong answer0/03ms1812 KiB
2Accepted0/032ms3408 KiB
3Wrong answer0/23ms2272 KiB
4Accepted2/23ms2480 KiB
5Wrong answer0/23ms2724 KiB
6Wrong answer0/24ms3172 KiB
7Accepted2/26ms3384 KiB
8Accepted2/24ms3392 KiB
9Wrong answer0/26ms3604 KiB
10Wrong answer0/24ms3856 KiB
11Accepted2/232ms5100 KiB
12Wrong answer0/232ms5008 KiB
13Wrong answer0/232ms5136 KiB
14Wrong answer0/232ms5144 KiB
15Accepted2/232ms5264 KiB
16Wrong answer0/232ms5352 KiB
17Wrong answer0/232ms5476 KiB
18Wrong answer0/232ms5840 KiB
19Wrong answer0/232ms5896 KiB
20Accepted2/232ms5708 KiB
21Wrong answer0/232ms5800 KiB
22Wrong answer0/232ms6068 KiB
23Wrong answer0/232ms5944 KiB
24Wrong answer0/232ms6032 KiB
25Wrong answer0/232ms6008 KiB
26Wrong answer0/232ms5916 KiB
27Wrong answer0/232ms6048 KiB