Submission #210218

#TimeUsernameProblemLanguageResultExecution timeMemory
210218super_j6Bigger segments (IZhO19_segments)C++14
27 / 100
1576 ms13816 KiB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const long long inf = 1000000000000007;
const int maxn = 3000;
int n;
int a[maxn];
long long dp[maxn][maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
		dp[0][i] = a[i] + (i ? dp[0][i - 1] : 0);
	} 
	
	int ret = 1;
	for(int i = 1; i < n; i++)
	for(int j = 0; j < n; j++){
		dp[i][j] = inf;
		for(long long k = j - 1, s = a[j]; k >= 0; k--){
			if(dp[i - 1][k] <= s){
				dp[i][j] = s;
				break;
			} 
			s += a[k];
		}
		if(dp[i][j] != inf) ret = i + 1;
	}
	
	
	cout << ret << 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...