18692022-12-06 19:40:36TomaSajtLeggyorsabb pénzkeresés (50)cpp17Wrong answer 24/5013ms5004 KiB
#include <bits/stdc++.h>
#define speed ios::sync_with_stdio(0);cin.tie(0)
using namespace std;

int main() {
    speed;
    int n, p;
    cin >> n >> p;
    vector<int> v(n);
    for (auto& a : v) cin >> a;
    int l = 0, r = -1;
    int best = INT_MAX;
    int s = 0;
    while (r < n) {
        while (s >= p) {
            s -= v[l];
            l++;
        }
        while (s < p && r < n) {
            r++;
            s += v[r];
        }
        best = min(best, r - l + 1);
    }
    cout << best;
}
SubtaskSumTestVerdictTimeMemory
base24/50
1Wrong answer0/03ms1828 KiB
2Wrong answer0/013ms2712 KiB
3Accepted2/22ms2124 KiB
4Wrong answer0/22ms2328 KiB
5Accepted2/22ms2552 KiB
6Wrong answer0/23ms2904 KiB
7Accepted2/23ms3108 KiB
8Accepted2/23ms3052 KiB
9Accepted2/23ms3308 KiB
10Accepted2/23ms3256 KiB
11Accepted2/213ms4036 KiB
12Wrong answer0/213ms4108 KiB
13Wrong answer0/213ms4112 KiB
14Wrong answer0/213ms4188 KiB
15Wrong answer0/213ms4316 KiB
16Accepted2/213ms4592 KiB
17Wrong answer0/213ms4680 KiB
18Wrong answer0/213ms4764 KiB
19Wrong answer0/213ms4828 KiB
20Accepted2/213ms4796 KiB
21Accepted2/213ms4932 KiB
22Wrong answer0/213ms5004 KiB
23Accepted2/213ms4928 KiB
24Accepted2/213ms4924 KiB
25Wrong answer0/213ms4928 KiB
26Wrong answer0/213ms4924 KiB
27Wrong answer0/213ms5000 KiB