This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
#define ld long double
const int N = 1e3 + 10;
vector<int> v;
ld a[N];
ld b[N];
int n;
ld ans = 0;
ld dp1[N][N];
ld dp2[N][N];
signed main(){
cout<<fixed<<setprecision(4);
cin>>n;
for (int i=1;i<=n;i++)
cin>>a[i]>>b[i];
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
dp1[i][j] = max(dp1[i-1][j],dp1[i-1][j-1] + a[i] - 1);
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
dp2[i][j] = max(dp2[i-1][j],dp2[i-1][j-1] + b[i] - 1);
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
ans = max(ans,min(dp1[n][i] - j, dp2[n][j] - i));
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |