241752026-02-05 17:12:59szentedLeggyorsabb pénzkeresés (50)cpp17Wrong answer 18/5032ms804 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    int p;
    int a[100000];
    cin >> n;
    cin >> p;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    int s=0;
    int mini_napok=n;
    int napok=0;
    int i=0;

    int kezd=0;
    int veg=0;

    while(kezd<n){
        
        if(s<p){
            s=s+a[veg];
            napok++;
            veg++;
        }
        else{
            if(s>=p){
                if(napok<mini_napok) mini_napok=napok;
                s=s-a[kezd];
                kezd++;
                napok--;
                
            }
        }
    }
    cout << mini_napok;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/01ms500 KiB
2Wrong answer0/030ms564 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/24ms408 KiB
7Accepted2/24ms412 KiB
8Accepted2/24ms316 KiB
9Accepted2/24ms408 KiB
10Accepted2/24ms316 KiB
11Accepted2/230ms768 KiB
12Wrong answer0/230ms716 KiB
13Wrong answer0/230ms760 KiB
14Wrong answer0/230ms760 KiB
15Wrong answer0/230ms588 KiB
16Wrong answer0/230ms564 KiB
17Wrong answer0/230ms564 KiB
18Wrong answer0/230ms564 KiB
19Wrong answer0/230ms564 KiB
20Wrong answer0/230ms668 KiB
21Wrong answer0/230ms564 KiB
22Wrong answer0/230ms564 KiB
23Wrong answer0/230ms612 KiB
24Wrong answer0/232ms564 KiB
25Wrong answer0/230ms580 KiB
26Wrong answer0/230ms564 KiB
27Wrong answer0/230ms804 KiB