66522023-12-15 11:55:43tamasmarkLeggyorsabb pénzkeresés (50)cpp17Time limit exceeded 44/50254ms5400 KiB
#include <iostream>
#include <vector>

using namespace std;

int n, i, mini, p, j, sum, db, a;
vector<long long>x;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> p;
    x.resize(n + 1);
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i];
    }
    i = 1;
    mini = 99999;
    while (i <= n)
    {
        if (sum == 0) a = i;
        sum += x[i];
        db++;
        if (sum >= p)
        {
            if (db < mini) mini = db;
            db = 0;
            sum = 0;
            i = a + 1;
        }
        else i++;
    }
    cout << mini;
    return 0;
}
/*
8 11
3 6 4 2 3 7 2 9

*/
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/03ms1892 KiB
2Time limit exceeded0/0241ms3580 KiB
3Accepted2/23ms2456 KiB
4Accepted2/23ms2628 KiB
5Accepted2/23ms2864 KiB
6Accepted2/27ms3184 KiB
7Accepted2/217ms3328 KiB
8Accepted2/223ms3544 KiB
9Accepted2/27ms3448 KiB
10Accepted2/219ms3456 KiB
11Accepted2/214ms4700 KiB
12Time limit exceeded0/2254ms4956 KiB
13Accepted2/2173ms5044 KiB
14Accepted2/257ms5052 KiB
15Accepted2/2171ms5200 KiB
16Accepted2/254ms5272 KiB
17Accepted2/248ms5184 KiB
18Accepted2/276ms5400 KiB
19Time limit exceeded0/2214ms5056 KiB
20Accepted2/2141ms5056 KiB
21Accepted2/285ms5052 KiB
22Accepted2/2119ms5200 KiB
23Time limit exceeded0/2245ms5208 KiB
24Accepted2/2115ms5056 KiB
25Accepted2/2149ms5052 KiB
26Accepted2/282ms5200 KiB
27Accepted2/279ms5052 KiB