Submission #993697

#TimeUsernameProblemLanguageResultExecution timeMemory
993697simona1230Tortoise (CEOI21_tortoise)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n,a[1001]; void read() { cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; } int dp[1001][2001]; void solve() { for(int i=0;i<=n;i++) { for(int j=0;j<=2*n;j++) { dp[i][j]=-1e9; } } for(int i=1;i<=n;i++) { for(int j=i;j<=2*i;j++) { if(a[i]==1)dp[i][j]=1; } } int ans=0; dp[0][0]=0; for(int i=1;i<=n;i++) { for(int j=1;j<=2*i;j++) { for(int pr=1;pr<i;pr++) { if(a[pr]!=1)continue; for(int d=1;d<=n;d++) { if(a[d]!=-1)continue; int f=j-(abs(d-i)+abs(d-pr)); if(f>=0)dp[i][j]=max(dp[i][j],dp[pr][f]+1); } } cout<<i<<" "<<j<<" "<<dp[i][j]<<endl; ans=max(ans,dp[i][j]); } } cout<<ans<<endl; } int main() { speed(); read(); 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...