95752024-02-23 11:31:48zeytonxLeggyorsabb pénzkeresés (50)cpp17Accepted 50/5014ms5948 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef vector<vll> v2ll;
typedef map<ll,ll> mll;
typedef vector<pll> vpll;
#define fs first
#define sc second
#define pb push_back

const ll MOD = 1e9+7;

void solve()
{
    ll n, p;
    cin >> n >> p;
    vll v(n);
    ll ans = 1e10;
    ll start = 0;
    ll csum = 0;
    for(ll i = 0; i < n; i++)
    {
        cin >> v[i];
        csum += v[i];
        while(start <= i && csum >= p)
        {
            ans = min(ans, i-start+1);
            csum -= v[start];
            start++;
        }
    }
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1976 KiB
2Accepted0/014ms3644 KiB
3Accepted2/23ms2264 KiB
4Accepted2/23ms2276 KiB
5Accepted2/23ms2428 KiB
6Accepted2/24ms2852 KiB
7Accepted2/24ms2808 KiB
8Accepted2/24ms3068 KiB
9Accepted2/24ms3020 KiB
10Accepted2/24ms3036 KiB
11Accepted2/214ms4552 KiB
12Accepted2/214ms4764 KiB
13Accepted2/214ms4972 KiB
14Accepted2/214ms5188 KiB
15Accepted2/214ms5400 KiB
16Accepted2/214ms5144 KiB
17Accepted2/214ms5140 KiB
18Accepted2/214ms5268 KiB
19Accepted2/214ms5340 KiB
20Accepted2/214ms5392 KiB
21Accepted2/214ms5464 KiB
22Accepted2/214ms5460 KiB
23Accepted2/214ms5328 KiB
24Accepted2/214ms5656 KiB
25Accepted2/214ms5540 KiB
26Accepted2/214ms5820 KiB
27Accepted2/214ms5948 KiB