이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |