87142024-01-26 11:09:53KaukazusLeggyorsabb pénzkeresés (50)cpp17Wrong answer 2/50300ms12424 KiB
#include <bits/stdc++.h>
#include <deque>
using namespace std;
#define ll long long

int main() {
	ll n,p;
	cin>> n >> p;
	deque<ll> tomb;
	ll osszeg=0, veg=n;
	for(int i=0;i<n;i++){
		int valt; cin >>valt;
		osszeg+=valt;
		tomb.push_back(valt);
		//cerr << valt << "     ";
		
		if(osszeg>=p){
			/*for(int x=0;x<tomb.size();x++){
				cerr << tomb[x] << " ";
			}*/
			cerr << endl << endl;
			if(tomb.size()<veg) veg=tomb.size();
			osszeg-=tomb.front();
			tomb.pop_front();
		} 
		
	
	}
	while(!tomb.empty()){
		osszeg-=tomb.front();
			tomb.pop_front();
		if(osszeg>=p){
			if(tomb.size()<veg) veg=tomb.size();
		}
		else break;
	}
	cout << veg;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Wrong answer0/03ms1808 KiB
2Time limit exceeded0/0238ms2532 KiB
3Wrong answer0/23ms2748 KiB
4Wrong answer0/23ms2964 KiB
5Accepted2/23ms3180 KiB
6Wrong answer0/229ms3272 KiB
7Wrong answer0/223ms3536 KiB
8Wrong answer0/234ms3892 KiB
9Wrong answer0/226ms3804 KiB
10Wrong answer0/237ms4140 KiB
11Time limit exceeded0/2275ms3860 KiB
12Time limit exceeded0/2232ms5300 KiB
13Time limit exceeded0/2229ms6044 KiB
14Time limit exceeded0/2236ms6492 KiB
15Time limit exceeded0/2232ms7092 KiB
16Time limit exceeded0/2234ms7528 KiB
17Time limit exceeded0/2233ms8044 KiB
18Time limit exceeded0/2226ms8472 KiB
19Time limit exceeded0/2237ms9148 KiB
20Time limit exceeded0/2228ms9528 KiB
21Time limit exceeded0/2232ms10000 KiB
22Time limit exceeded0/2232ms10484 KiB
23Time limit exceeded0/2232ms11108 KiB
24Time limit exceeded0/2231ms11448 KiB
25Time limit exceeded0/2268ms11460 KiB
26Time limit exceeded0/2273ms11964 KiB
27Time limit exceeded0/2300ms12424 KiB