44522023-03-28 10:51:49ZsofiaKeresztelyLeggyorsabb pénzkeresés (50)cpp14Wrong answer 46/5032ms5436 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, p;
    cin >> n >> p;
    vector<int> a(n+1, 0);
    int l=0, r=1, sum=0;
    while (sum < p){
        cin >> a[r];
        sum += a[r];
        r++;
    }
    int op = r;
    while (r<=n){
        cin >> a[r];
        sum += a[r];
        while (sum-a[l+1] >= p){
            l++;
            sum -= a[l];
        }
        op = min(op, r-l);
        r++;
    }
    cout << op;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/03ms1808 KiB
2Accepted0/032ms2716 KiB
3Accepted2/23ms2220 KiB
4Accepted2/23ms2428 KiB
5Wrong answer0/23ms2672 KiB
6Accepted2/24ms2764 KiB
7Accepted2/24ms2760 KiB
8Accepted2/24ms3100 KiB
9Accepted2/24ms3096 KiB
10Accepted2/24ms3304 KiB
11Accepted2/232ms4060 KiB
12Accepted2/232ms4276 KiB
13Accepted2/232ms4480 KiB
14Accepted2/232ms4504 KiB
15Accepted2/232ms4636 KiB
16Accepted2/232ms4832 KiB
17Accepted2/232ms4916 KiB
18Accepted2/232ms5008 KiB
19Accepted2/232ms4916 KiB
20Accepted2/232ms5040 KiB
21Accepted2/232ms5124 KiB
22Accepted2/232ms5124 KiB
23Wrong answer0/232ms5220 KiB
24Accepted2/232ms5256 KiB
25Accepted2/232ms5228 KiB
26Accepted2/232ms5352 KiB
27Accepted2/232ms5436 KiB