44512023-03-28 10:49:05ZsofiaKeresztelyLeggyorsabb pénzkeresés (50)cpp14Wrong answer 46/5032ms5028 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/03ms1816 KiB
2Accepted0/032ms2712 KiB
3Accepted2/23ms2216 KiB
4Accepted2/23ms2300 KiB
5Wrong answer0/23ms2576 KiB
6Accepted2/24ms2880 KiB
7Accepted2/24ms2776 KiB
8Accepted2/24ms2836 KiB
9Accepted2/24ms2836 KiB
10Accepted2/26ms3092 KiB
11Accepted2/232ms3840 KiB
12Accepted2/232ms3928 KiB
13Accepted2/232ms3928 KiB
14Accepted2/232ms4024 KiB
15Accepted2/232ms4252 KiB
16Accepted2/232ms4364 KiB
17Accepted2/232ms4468 KiB
18Accepted2/232ms4468 KiB
19Accepted2/232ms4600 KiB
20Accepted2/232ms4684 KiB
21Accepted2/232ms4808 KiB
22Accepted2/232ms4892 KiB
23Wrong answer0/232ms4804 KiB
24Accepted2/232ms4808 KiB
25Accepted2/232ms4812 KiB
26Accepted2/232ms4940 KiB
27Accepted2/232ms5028 KiB