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

using namespace std;

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

    int epp=0;
    int mini=n;
    int 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/03ms1812 KiB
2Accepted0/032ms2708 KiB
3Accepted2/23ms2228 KiB
4Accepted2/23ms2428 KiB
5Wrong answer0/22ms2512 KiB
6Accepted2/24ms2796 KiB
7Accepted2/24ms2780 KiB
8Accepted2/26ms3120 KiB
9Accepted2/24ms3076 KiB
10Accepted2/24ms3160 KiB
11Accepted2/232ms3828 KiB
12Accepted2/232ms3872 KiB
13Accepted2/232ms3952 KiB
14Accepted2/232ms4232 KiB
15Accepted2/232ms4228 KiB
16Accepted2/232ms4480 KiB
17Accepted2/232ms4548 KiB
18Accepted2/232ms5024 KiB
19Accepted2/232ms5004 KiB
20Accepted2/232ms4956 KiB
21Accepted2/232ms5184 KiB
22Accepted2/232ms5184 KiB
23Wrong answer0/232ms5184 KiB
24Accepted2/232ms5184 KiB
25Accepted2/232ms5192 KiB
26Accepted2/232ms5196 KiB
27Accepted2/232ms5148 KiB