44532023-03-28 10:52:40ZsofiaKeresztelyLeggyorsabb pénzkeresés (50)cpp14Accepted 50/5032ms5068 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-1;
    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
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/032ms2708 KiB
3Accepted2/23ms2228 KiB
4Accepted2/23ms2316 KiB
5Accepted2/23ms2440 KiB
6Accepted2/26ms2864 KiB
7Accepted2/24ms2796 KiB
8Accepted2/26ms3056 KiB
9Accepted2/24ms3092 KiB
10Accepted2/24ms3356 KiB
11Accepted2/232ms4100 KiB
12Accepted2/232ms4464 KiB
13Accepted2/232ms4480 KiB
14Accepted2/232ms4460 KiB
15Accepted2/232ms4672 KiB
16Accepted2/232ms4776 KiB
17Accepted2/232ms4888 KiB
18Accepted2/232ms4972 KiB
19Accepted2/232ms5068 KiB
20Accepted2/232ms5068 KiB
21Accepted2/232ms4952 KiB
22Accepted2/232ms4956 KiB
23Accepted2/232ms4952 KiB
24Accepted2/232ms4952 KiB
25Accepted2/232ms5052 KiB
26Accepted2/232ms4952 KiB
27Accepted2/232ms4952 KiB