제출 #210224

#제출 시각아이디문제언어결과실행 시간메모리
210224super_j6Bigger segments (IZhO19_segments)C++14
0 / 100
5 ms376 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 = 0; i < n; i++)
	for(int j = 0; j < n; j++){
		if(!dp[i][j]) continue;
		else ret = i + 1;
		int it = lower_bound(dp[0], dp[0] + n, dp[i][j] + dp[0][j]) - dp[0];
		if(it < n) dp[i + 1][it] = dp[0][it] - dp[0][j];
	}
	
	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...