제출 #210225

#제출 시각아이디문제언어결과실행 시간메모리
210225super_j6Bigger segments (IZhO19_segments)C++14
13 / 100
5 ms376 KiB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<long long, long long>
#define f first
#define s second
 
const int maxn = 500000;
int n;
int a[maxn];
pi dp[maxn];
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 1; i <= n; i++){
		for(int j = i - 1, s = a[i]; j >= 0; j--){
			if(dp[j].f >= dp[i].f && s >= dp[j].s) dp[i] = {dp[j].f + 1, s};
			s += a[j];
		}
	}
	
	cout << dp[n].f << endl;
 
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...