6631 | 2023. 12. 14 07:47:20 | zsebi | Leggyorsabb pénzkeresés (50) | cpp17 | Időlimit túllépés 46/50 | 214ms | 6232 KiB |
// leggyors_penzkereses.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <queue>
#include <algorithm>
#define ll long long
using namespace std;
ll n, p, maxi = 0;
int main()
{
cin >> n >> p;
vector<ll>x(n + 1);
for (int i = 1; i <= n; ++i)
{
ll a;
cin >> a;
x[i] = x[i - 1] + a;
if (a >= p)
{
cout << "1";
return 0;
}
}
if (x[n] < p)
{
cout << "0";
return 0;
}
ll mintav = n;
for (int i = 1; i <= n; ++i)
{
ll sum;
for (int j = i - 1; j > i - mintav + 1; --j)
{
if (j > 0)
{
sum=x[i]-x[j-1];
if (sum >= p)
{
mintav = i - j + 1;
break;
}
}
else break;
}
}
cout << mintav;
return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
base | 46/50 | ||||||
1 | Elfogadva | 0/0 | 3ms | 1816 KiB | |||
2 | Időlimit túllépés | 0/0 | 203ms | 3532 KiB | |||
3 | Elfogadva | 2/2 | 3ms | 2344 KiB | |||
4 | Elfogadva | 2/2 | 3ms | 2600 KiB | |||
5 | Elfogadva | 2/2 | 3ms | 2508 KiB | |||
6 | Elfogadva | 2/2 | 8ms | 2964 KiB | |||
7 | Elfogadva | 2/2 | 17ms | 3176 KiB | |||
8 | Elfogadva | 2/2 | 21ms | 3296 KiB | |||
9 | Elfogadva | 2/2 | 8ms | 3088 KiB | |||
10 | Elfogadva | 2/2 | 18ms | 3084 KiB | |||
11 | Elfogadva | 2/2 | 30ms | 4496 KiB | |||
12 | Időlimit túllépés | 0/2 | 214ms | 4708 KiB | |||
13 | Elfogadva | 2/2 | 151ms | 4920 KiB | |||
14 | Elfogadva | 2/2 | 61ms | 5128 KiB | |||
15 | Elfogadva | 2/2 | 149ms | 5268 KiB | |||
16 | Elfogadva | 2/2 | 59ms | 5356 KiB | |||
17 | Elfogadva | 2/2 | 57ms | 5356 KiB | |||
18 | Elfogadva | 2/2 | 76ms | 5352 KiB | |||
19 | Elfogadva | 2/2 | 182ms | 5564 KiB | |||
20 | Elfogadva | 2/2 | 126ms | 5660 KiB | |||
21 | Elfogadva | 2/2 | 82ms | 5624 KiB | |||
22 | Elfogadva | 2/2 | 108ms | 5660 KiB | |||
23 | Időlimit túllépés | 0/2 | 206ms | 5664 KiB | |||
24 | Elfogadva | 2/2 | 105ms | 5892 KiB | |||
25 | Elfogadva | 2/2 | 131ms | 6092 KiB | |||
26 | Elfogadva | 2/2 | 79ms | 6232 KiB | |||
27 | Elfogadva | 2/2 | 79ms | 6104 KiB |