Submission #684890

#TimeUsernameProblemLanguageResultExecution timeMemory
684890sidonCigle (COI21_cigle)C++17
100 / 100
645 ms391820 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t #define z(X, Y) (X = max(X, Y)) signed main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; int d[N]; for(int &i : d) cin >> i; int dp[N][N] {}, c[N][N] {}, ans {}; for(int i = 1; i < N; ++i) { int sum[2] {}, k = i - 1, cnt {}; for(int j = i; j < N; ++j) { int f = -1; for(; k >= 0 && sum[0] + d[k] < sum[1] + d[j]; --k) { if((sum[0] += d[k]) == sum[1]) ++cnt, f = k; } sum[1] += d[j]; if(f > 0) z(dp[i][j], c[f - 1][i-1] + cnt); z(dp[i][j], dp[i][j-1]); z(ans, dp[i][j]); } for(int j = 0; j <= i; ++j) c[j][i] = dp[j][i]; for(int j = 1; j <= i; ++j) z(c[j][i], c[j-1][i]); } cout << ans; }
#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...