This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
بسم الله الرحمن الرحيم
Author:
(:Muhammad Aneeq:)
*/
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ld long double
inline void solve()
{
int n;
cin>>n;
vector<ld>a,b;
for (int i=0;i<n;i++)
{
ld x,y;
cin>>x>>y;
a.push_back(x);
b.push_back(y);
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
sort(b.begin(), b.end());
reverse(b.begin(), b.end());
ld ans=0;
int i=0,j=0;
ld sa=0,sb=0;
while (i<n||j<n)
{
if (i==n||sa>sb)
sb+=b[j++];
else
sa+=a[i++];
ans=max(ans,min(sb-(i+j),sa-(i+j)));
}
printf("%.4lf\n",(double)ans);
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |