18722022-12-06 20:30:45TomaSajtLeggyorsabb pénzkeresés (50)cpp17Wrong answer 46/5013ms6212 KiB
#include <bits/stdc++.h>
#define speed ios::sync_with_stdio(0);cin.tie(0)
using namespace std;
#define int long long
signed 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 = LLONG_MAX;
    int s = 0;
    while (1) {
        if (s >= p) {
            s -= v[l];
            l++;
            if (s >= p) best = min(best, r - l + 1);
        }
        else {
            r++;
            if (r == n) break;
            s += v[r];
        }
    }
    cout << best;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/03ms2108 KiB
2Accepted0/012ms3612 KiB
3Accepted2/22ms2500 KiB
4Accepted2/22ms2452 KiB
5Wrong answer0/22ms2672 KiB
6Accepted2/23ms3084 KiB
7Accepted2/23ms3264 KiB
8Accepted2/23ms3408 KiB
9Accepted2/23ms3684 KiB
10Accepted2/23ms3592 KiB
11Accepted2/212ms4852 KiB
12Accepted2/212ms5100 KiB
13Accepted2/212ms5052 KiB
14Accepted2/213ms5180 KiB
15Accepted2/212ms5468 KiB
16Accepted2/213ms5332 KiB
17Accepted2/213ms5652 KiB
18Accepted2/212ms5656 KiB
19Accepted2/213ms5972 KiB
20Accepted2/213ms6180 KiB
21Accepted2/212ms6168 KiB
22Accepted2/212ms6212 KiB
23Wrong answer0/212ms5972 KiB
24Accepted2/213ms5972 KiB
25Accepted2/212ms5976 KiB
26Accepted2/212ms6036 KiB
27Accepted2/212ms6036 KiB