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;
inline double in() {
double result=0, d=1;
char ch = getchar_unlocked();
while(true) {
if(ch >= '0' && ch <= '9')
break;
ch = getchar_unlocked();
}
result = ch-'0';
while(true) {
ch = getchar_unlocked();
if (ch < '0' || ch > '9')
break;
result = result*10 + (ch - '0');
}
if(ch=='.') {
while(true) {
ch = getchar_unlocked();
if (ch < '0' || ch > '9')
break;
result += (ch - '0')/(d*=10);
}
}
return result;
}
inline void out(int x) {
int rev=x, c=0;
if(!x) {
putchar_unlocked('0');
return;
}
while(!(rev%10)) {
++c;
rev/=10;
}
rev=0;
while(x) {
rev=rev*10+x%10;
x/=10;
}
while(rev) {
putchar_unlocked(rev%10+'0');
rev/=10;
}
while(c--)
putchar_unlocked('0');
}
const int mxN=1e5;
int n;
double a[mxN+1], b[mxN+1], ans, sa, sb;
int main() {
n=in();
for(int i=0; i<n; ++i)
a[i]=in(), b[i]=in();
sort(a, a+n+1);
sort(b, b+n+1);
for(int i1=n, i2=n; i1>=0&&i2>=0; ) {
if(sa<sb)
sa+=a[i1--];
else
sb+=b[i2--];
ans=max(min(sa, sb)-(n-i1)-(n-i2), ans);
}
ans+=0.00005;
out(ans);
putchar_unlocked('.');
ans=ans-(int)ans;
for(int i=0; i<4; ++i) {
ans*=10;
putchar_unlocked((int)ans%10+'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... |