10192022-02-24 21:27:45Szin AttilaLeggyorsabb pénzkeresés (50)cpp14Accepted 50/5024ms11532 KiB
#include <bits/stdc++.h>
using namespace std;
#define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using ll = long long;

const int maxN = 2e5 + 5;
const int MOD = 1e9 + 7;


int main() {
   InTheNameOfGod;


    ll n,m;
    cin >> n >> m;

    vector<int> v(n);
    for(int &i : v) cin >> i;

    int last = 0, sum = 0, mo = INT_MAX;
    for(int i = 0; i < n; i++) {
        sum += v[i];
        while(sum - v[last] >= m && last < i) {
            sum -= v[last++];
        }

        if(sum >= m) mo = min(mo, i - last + 1);
    }

    cout << mo;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1736 KiB
2Accepted0/010ms3000 KiB
3Accepted2/21ms2348 KiB
4Accepted2/21ms2356 KiB
5Accepted2/21ms2364 KiB
6Accepted2/22ms2412 KiB
7Accepted2/22ms2456 KiB
8Accepted2/22ms2500 KiB
9Accepted2/22ms2552 KiB
10Accepted2/22ms2604 KiB
11Accepted2/214ms3828 KiB
12Accepted2/210ms4308 KiB
13Accepted2/210ms4788 KiB
14Accepted2/212ms5276 KiB
15Accepted2/212ms5760 KiB
16Accepted2/210ms6240 KiB
17Accepted2/210ms6716 KiB
18Accepted2/210ms7200 KiB
19Accepted2/210ms7688 KiB
20Accepted2/210ms8168 KiB
21Accepted2/210ms8648 KiB
22Accepted2/210ms9124 KiB
23Accepted2/210ms9612 KiB
24Accepted2/224ms10092 KiB
25Accepted2/210ms10572 KiB
26Accepted2/212ms11056 KiB
27Accepted2/210ms11532 KiB