Submission #1002857

#TimeUsernameProblemLanguageResultExecution timeMemory
1002857hyakupCigle (COI21_cigle)C++17
20 / 100
46 ms2140 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define bug(x) cout << #x << " " << x << endl; #define pii pair<int, int> const int inf = 1e9 + 10; const int maxn = 500; const int maxm = 3e7 + 10; vector<int> v( maxn ); ll dp[maxn][maxn]; bool marc[maxm]; int main(){ int n; cin >> n; for( int i = 1; i <= n; i++ ) cin >> v[i]; ll resp = 0; for( int a = 1; a <= n; a++){ for( int b = 1; b < a; b++ ){ int sum = 0; for( int i = b + 1; i < a; i++ ){ sum += v[i]; marc[sum] = true; } sum = 0; ll& ans = dp[a][b]; int cont = 0; for( int c = b - 1; c >= 0; c-- ){ if( marc[sum] ) cont++; sum += v[c + 1]; ans = max( ans, dp[b][c] + cont ); } sum = 0; for( int i = b + 1; i < a; i++ ){ sum += v[i]; marc[sum] = false; } resp = max( resp, ans ); } } cout << resp << endl; }
#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...