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 = 1e5 + 10;
vector<int> v;
ld a[N];
ld b[N];
int n;
ld ans = 0;
bool valid(int ind = n){
if (ind==0)
return false;
if (v[ind]<2){
v[ind]++;
return true;
}
v[ind] = 0;
return valid(ind-1);
}
void calculate(){
ld sum1 = 0,sum2 = 0;
ld cnt = 0;
for (int i=1;i<=n;i++)
if (v[i]==1)
sum1 += a[i],cnt++;
else if (v[i]==2)
sum2 += b[i],cnt++;
ans = max(ans,min(sum1,sum2) - cnt);
}
signed main(){
cout<<fixed<<setprecision(4);
cin>>n;
for (int i=1;i<=n;i++)
cin>>a[i]>>b[i];
for (int i=0;i<=n;i++)
v.push_back(0);
while (valid()){
calculate();
}
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... |