237962026-01-29 19:07:31szentedLeggyorsabb pénzkeresés (50)cpp17Wrong answer 6/5029ms832 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 j=0;
    int napok=0;

    int i=0;
    while(i<n){
        napok=0;
        j=i;
        s=0;
        while(s<p && j<n){
            s=s+a[j];
            j++;
            napok++;
        }
        if(napok<mini_napok && s>=p) mini_napok=napok;
        if(napok>1) i=i+napok-1;
        else i++;
    }
    cout << mini_napok;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Wrong answer0/01ms508 KiB
2Wrong answer0/028ms564 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Accepted2/21ms316 KiB
6Wrong answer0/24ms316 KiB
7Wrong answer0/24ms316 KiB
8Wrong answer0/24ms316 KiB
9Wrong answer0/24ms316 KiB
10Wrong answer0/24ms316 KiB
11Accepted2/229ms788 KiB
12Wrong answer0/229ms684 KiB
13Wrong answer0/228ms744 KiB
14Wrong answer0/228ms772 KiB
15Wrong answer0/229ms564 KiB
16Wrong answer0/229ms564 KiB
17Wrong answer0/229ms640 KiB
18Wrong answer0/229ms712 KiB
19Wrong answer0/229ms584 KiB
20Wrong answer0/229ms564 KiB
21Wrong answer0/229ms564 KiB
22Wrong answer0/229ms564 KiB
23Accepted2/229ms600 KiB
24Wrong answer0/228ms668 KiB
25Wrong answer0/229ms692 KiB
26Wrong answer0/229ms700 KiB
27Wrong answer0/229ms832 KiB