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 <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
void output(double p1, double p2)
{
if(p1 < 0 ||p2<0)
printf("%.4lf", (double)(0));
else
printf("%.4lf", (double)(min(p1, p2)));
}
int main()
{
int n; cin>>n;
vector<long double> odds1(n), odds2(n);
for(int i = 0; i<n; ++i)
{
cin>>odds1[i]>>odds2[i];
}
sort(odds1.rbegin(), odds1.rend());
sort(odds2.rbegin(), odds2.rend());
vector<long double> prefSum1(n);
vector<long double> prefSum2(n);
prefSum1[0] = odds1[0];
prefSum2[0] = odds2[0];
for(int i =1; i<n; ++i)
{
prefSum1[i] = prefSum1[i-1]+odds1[i];
prefSum2[i] = prefSum2[i-1]+ odds2[i];
}
long double bestSureProf = 0;
for(int i = 0; i<n; ++i)
{
for(int j = 0; j<n; ++j)
{
long double p1 = prefSum1[i]- (i+1) - (j+1);
long double p2 = prefSum2[j] - (i+1) - (j+1);
if(min(p1,p2) > bestSureProf)
bestSureProf = min(p1,p2);
}
}
output(bestSureProf, bestSureProf);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |