150052025-02-11 07:24:30BencuLeggyorsabb pénzkeresés (50)cpp17Wrong answer 8/5030ms772 KiB
#include <bits/stdc++.h>

using namespace std;
int n,p,a[100001],m=INT_MAX;

int main()
{
    ifstream f("be.in");
    //f>>n>>p;
    cin>>n>>p;
    for (int i=1; i<=n; i++) {
        //f>>a[i];
        cin>>a[i];
    }
    /*for (int i=1; i<=n; i++) {
        int s=a[i],j=i,t=1;
        //cout<<i<<":"<<s<<" ";
        while (s<p && j<n) {
            j++;
            s=s+a[j];
            //cout<<s<<" ";
            t++;
        }
        //cout<<endl;
        if (t<m && s>=p) m=t;
    }*/
    int i=1;
    int s=a[1],j=1,t=1;
    while (s<p) {
        j++;
        s=s+a[j];
        t++;
    }
    m=t;
    j++;
    while (j<n) {
        if ((((s-a[i])-a[i+1])+a[j])>=p) {
            i++;
            m--;
        }
        else j++;
    }
    cout<<m;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/01ms316 KiB
2Wrong answer0/028ms564 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Wrong answer0/24ms436 KiB
7Wrong answer0/24ms316 KiB
8Wrong answer0/23ms316 KiB
9Wrong answer0/24ms316 KiB
10Wrong answer0/24ms420 KiB
11Accepted2/228ms756 KiB
12Wrong answer0/228ms660 KiB
13Wrong answer0/228ms680 KiB
14Wrong answer0/228ms712 KiB
15Wrong answer0/228ms708 KiB
16Wrong answer0/228ms564 KiB
17Wrong answer0/228ms564 KiB
18Wrong answer0/228ms756 KiB
19Wrong answer0/228ms564 KiB
20Wrong answer0/228ms756 KiB
21Wrong answer0/228ms564 KiB
22Wrong answer0/228ms756 KiB
23Accepted2/230ms564 KiB
24Wrong answer0/228ms564 KiB
25Wrong answer0/228ms772 KiB
26Wrong answer0/229ms672 KiB
27Wrong answer0/228ms596 KiB