50142023-04-09 16:56:31Laci3000Leghosszabb nyaralás (75 pont)cpp17Time limit exceeded 38/75300ms4600 KiB

#include <vector>
#include <iostream>

using namespace std;

int innentol(vector<int> lista, int innen, int maximum){
    int ar  = 0;  
	int napokszama = 0;
	for (int i = innen; i < lista.size(); i++)
	{
		if (ar + lista[i] <= maximum) {
			ar += lista[i];
			napokszama++;
		}
		else {
			break;
		}
	}
	return napokszama;
}
int megoldo() {
	int napokszama, penz;
	cin >> napokszama >> penz;
	vector<int>arak(napokszama);
	for (int i = 0; i < napokszama; i++)
	{
		cin >> arak[i];
	}
	vector<int>ertekek(napokszama);
	for (size_t i = 0; i < napokszama; i++)
	{
		ertekek[i] = innentol(arak, i, penz);
	}
	int keresett_ertek = ertekek[0];
	for (size_t i = 1; i < napokszama; i++)
	{
		if (keresett_ertek < ertekek[i]) {
			keresett_ertek = ertekek[i];
		}
	}
	return keresett_ertek;
}

int main()
{
	cout << megoldo();
}

SubtaskSumTestVerdictTimeMemory
base38/75
1Accepted0/03ms1680 KiB
2Time limit exceeded0/0300ms2412 KiB
3Accepted3/33ms2268 KiB
4Accepted3/33ms2392 KiB
5Accepted3/33ms2648 KiB
6Accepted3/33ms2860 KiB
7Accepted3/32ms3100 KiB
8Accepted4/43ms3280 KiB
9Accepted4/43ms3520 KiB
10Accepted5/53ms3528 KiB
11Accepted5/548ms3980 KiB
12Accepted5/535ms3936 KiB
13Time limit exceeded0/7263ms4252 KiB
14Time limit exceeded0/7270ms4284 KiB
15Time limit exceeded0/7263ms4364 KiB
16Time limit exceeded0/8259ms4600 KiB
17Time limit exceeded0/8239ms4464 KiB