Submission #1116226

#TimeUsernameProblemLanguageResultExecution timeMemory
1116226epicci23Cigle (COI21_cigle)C++17
48 / 100
1048 ms196680 KiB
#include "bits/stdc++.h" #define int long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() using namespace std; void _(){ int n; cin >> n; int ar[n+5]; for(int i=1;i<=n;i++) cin >> ar[i]; int dp[n+5][n+5]; memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++){ for(int j=i;j<=n;j++){ // last block starts from right to left vector<int> s; int sum = 0; for(int z = j; z > i; z--){ sum += ar[z]; s.push_back(sum); } int p = j + 1, cur = 0, cost = 0; int _p = 0; while(p <= n){ while(_p < sz(s) && s[_p] < cur) _p++; if(_p < sz(s) && s[_p] == cur) cost++; cur += ar[p]; dp[j+1][p] = max(dp[j+1][p], dp[i][j] + cost); p++; } // last block starts from left to right } } int ans = 0; for(int i=1;i<=n;i++) ans = max(ans, dp[i][n]); cout << ans << '\n'; } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); int tc=1;//cin >> tc; while(tc--) _(); return 0; }
#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...