Submission #684894

#TimeUsernameProblemLanguageResultExecution timeMemory
684894sidonCigle (COI21_cigle)C++17
100 / 100
284 ms196188 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] {}, ans {}; for(int i = 1; i < N; ++i) { int s0 {}, s1 {}, k = i - 1, cnt {}; for(int j = i, f {}; j < N; ++j) { for(; k >= 0 && s0 + d[k] < s1 + d[j]; --k) if((s0 += d[k]) == s1) ++cnt, f = k; s1 += d[j]; if(f > 0) z(dp[i][j], dp[f-1][i-1] + cnt); z(ans, z(dp[i][j], dp[i][j-1])); } for(int j = 1; j <= i; ++j) z(dp[j][i], dp[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...