Submission #887217

#TimeUsernameProblemLanguageResultExecution timeMemory
887217zeta7532Cigle (COI21_cigle)C++17
33 / 100
1006 ms1684 KiB
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using ll = int; const ll mod = 998244353; #define fi first #define se second #define rep(i,n) for(ll i=0;i<n;i++) #define all(x) x.begin(),x.end() #define faster ios::sync_with_stdio(false);cin.tie(nullptr) int main() { ll N; cin >> N; vector<ll> A(N); rep(i,N) cin >> A[i]; vector<vector<ll>> ep(N,vector<ll>(N,0)); rep(i,N){ for(ll j=i;j<N;j++){ set<ll> s; ll cnt_l=0; for(ll k=j;k>i;k--){ cnt_l+=A[k]; s.insert(cnt_l); } ll cnt=0; ll cnt_r=0; for(ll k=j+1;k<N;k++){ ep[j+1][k]=max(ep[j+1][k],ep[i][j]+cnt); cnt++; cnt_r+=A[k]; if(s.find(cnt_r)==s.end()) cnt--; } } } ll ans=0; rep(i,N) ans=max(ans,ep[i][N-1]); cout << ans << endl; 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...