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<bits/stdc++.h>
using namespace std;
int main()
{
int n ;
cin>>n;
vector<double> a(n) , b(n);
int sm1 = 0 , sm2 = 0;
for(int i = 0 ; i < n ; i++)
{
cin>>a[i]>>b[i];
sm1+=a[i] - 2;
sm2+=b[i] - 2;
}
double ans = 0;
for(int mask = 0 ; mask < (1<<(2 * n)) ; mask++)
{
double f = 0 , s = 0;
for(int i = 0 ; i < n ; i++)
{
int bit = (mask >> (2*i)) - 4 * (mask >> (2*(i + 1)));
if(bit == 0)
{
continue;
}
else if(bit == 1)
{
f+=a[i] - 1;
s--;
}
else if(bit == 2)
{
f--;
s+=b[i] - 1;
}
else
{
f+=a[i] - 2;
s+=b[i] - 2;
}
}
ans = max(ans , min(f , s));
}
printf("%.4lf",(double)ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |