48262023-03-31 12:57:47csaron71Leggyorsabb pénzkeresés (50)cpp17Wrong answer 46/5032ms5760 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=INT_MAX;
    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/03ms1680 KiB
2Accepted0/032ms2556 KiB
3Accepted2/23ms2068 KiB
4Accepted2/23ms2296 KiB
5Wrong answer0/23ms2224 KiB
6Accepted2/26ms2508 KiB
7Accepted2/24ms2724 KiB
8Accepted2/26ms3048 KiB
9Accepted2/26ms3148 KiB
10Accepted2/26ms3360 KiB
11Accepted2/232ms4112 KiB
12Accepted2/232ms4324 KiB
13Accepted2/232ms4532 KiB
14Accepted2/232ms4896 KiB
15Accepted2/232ms4896 KiB
16Accepted2/232ms4980 KiB
17Accepted2/232ms5320 KiB
18Accepted2/232ms5192 KiB
19Accepted2/232ms5184 KiB
20Accepted2/232ms5256 KiB
21Accepted2/232ms5528 KiB
22Accepted2/232ms5508 KiB
23Wrong answer0/232ms5596 KiB
24Accepted2/232ms5660 KiB
25Accepted2/232ms5664 KiB
26Accepted2/232ms5760 KiB
27Accepted2/232ms5756 KiB