Submission #878644

#TimeUsernameProblemLanguageResultExecution timeMemory
878644Faisal_SaqibSure Bet (CEOI17_sure)C++17
60 / 100
150 ms37212 KiB
#include <iostream> #include <vector> #include <cmath> #include <iomanip> using namespace std; const int N=1001; double dp[N][N]; double dp1[N][N]; int main() { cout<<fixed<<setprecision(4); int n; cin>>n; vector<double> a,b; for(int i=0;i<n;i++) { double x,y; cin>>x>>y; a.push_back(x); b.push_back(y); } for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp[i][j]=dp1[i][j]=-1e9; dp[0][0]=dp1[0][0]=0; for(int i=0;i<n;i++) { for(int j=0;j<=i;j++) { dp[i+1][j]=max(dp[i+1][j],dp[i][j]); dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+a[i]-1); dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j]); dp1[i+1][j+1]=max(dp1[i+1][j+1],dp1[i][j]+b[i]-1); } } double ans=0; for(int j=0;j<=n;j++) for(int i=0;i<=n;i++) ans=max(ans,min(dp[n][j]-i,dp1[n][i]-j)); cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...