# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
334202 | BeanZ | Bigger segments (IZhO19_segments) | C++14 | 90 ms | 71020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 3e3 + 5;
long long mod = 1e9 + 7;
const int lim = 5e5;
const int lg = 20;
const int base = 311;
const long double eps = 1e-6;
ll a[N], sum[N], dp[N][N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("test.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i];
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
dp[i][j] = -1e9;
}
}
for (int i = 1; i <= n; i++) dp[1][i] = 1;
for (int i = 2; i <= n; i++){
ll best = -1e9;
ll l = i - 1;
for (int j = i; j <= n; j++){
ll tot = sum[j] - sum[i - 1];
while (l > 0 && (sum[i - 1] - sum[l - 1]) <= tot){
best = max(best, dp[l][i - 1]);
l--;
}
dp[i][j] = best + 1;
}
}
//cout << dp[1][1] << " " << dp[2][3] << endl;
ll ans = 0;
for (int i = 1; i <= n; i++){
ans = max(ans, dp[i][n]);
}
cout << ans;
}
/*
Ans:
Out:
*/
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |