Submission #447170

#TimeUsernameProblemLanguageResultExecution timeMemory
447170FEDIKUSCigle (COI21_cigle)C++17
100 / 100
368 ms98500 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define xx first #define yy second #define srt(a) sort(a.begin(),a.end()); #define srtg(a,int) sort(a.begin(),a.end(),greater<int>()) #define lb(a,x) lower_bound(a.begin(),a.end(),x) #define up(a,x) upper_bound(a.begin(),a.end(),x) #define fnd(a,x) find(a.begin(),a.end(),x) #define vstart auto startt=chrono::system_clock::now() #define vend auto endd=chrono::system_clock::now() #define vvreme chrono::duration<double> vremee=endd-startt #define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef string str; const int maxn=5e3+10; int niz[maxn]; int dp[maxn][maxn]; void solve(){ int n; cin>>n; for(int i=1;i<=n;i++) cin>>niz[i]; for(int i=1;i<=n;i++){ for(int j=n;j>=0;j--){ dp[i][j]=max(dp[i][j],dp[i][j+1]); } int tren=i; int sum1=0; int sum2=0; int koliko=0; int maxi=0; for(int j=i+1;j<=n;j++){ sum1+=niz[j]; while(tren>=1 && sum2<sum1){ sum2+=niz[tren]; tren--; maxi=max(maxi,koliko+dp[i][i-tren]); } dp[j][j-i]=max(dp[j][j-i],maxi); if(sum1==sum2) koliko++; } } cout<<dp[n][0]; } int main(){ ios; int t=1; //cin>>t; while(t--) solve(); 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...