8662022-01-21 20:24:57Valaki2Leggyorsabb pénzkeresés (50)cpp14Wrong answer 2/5014ms11732 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int maxn = 1e5;

int n, p;
int v[1 + maxn];

void solve() {
    cin >> n >> p;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    int l = 1, r = 1, sum = 0, ans = n;
    while(l <= n) {
        while(r <= n && sum < p) {
            sum += v[r];
            r++;
        }
        ans = min(ans, r - l + 1);
        sum -= v[l];
        l++;
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Wrong answer0/02ms1884 KiB
2Wrong answer0/014ms3288 KiB
3Wrong answer0/22ms2480 KiB
4Wrong answer0/21ms2484 KiB
5Wrong answer0/22ms2492 KiB
6Wrong answer0/23ms2532 KiB
7Wrong answer0/23ms2584 KiB
8Wrong answer0/23ms2736 KiB
9Wrong answer0/22ms2680 KiB
10Wrong answer0/22ms2724 KiB
11Accepted2/210ms4020 KiB
12Wrong answer0/212ms4500 KiB
13Wrong answer0/210ms4980 KiB
14Wrong answer0/212ms5468 KiB
15Wrong answer0/210ms5816 KiB
16Wrong answer0/213ms6396 KiB
17Wrong answer0/212ms6908 KiB
18Wrong answer0/214ms7388 KiB
19Wrong answer0/212ms7876 KiB
20Wrong answer0/210ms8328 KiB
21Wrong answer0/212ms8780 KiB
22Wrong answer0/29ms9284 KiB
23Wrong answer0/210ms9772 KiB
24Wrong answer0/212ms10208 KiB
25Wrong answer0/213ms10672 KiB
26Wrong answer0/212ms11252 KiB
27Wrong answer0/214ms11732 KiB