이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
double a[100001], b[100001];
int main(){
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
//ifstream cin;
//ofstream cout;
//cin.open("input.txt");
//cout.open("output.txt");
int n;
cin >> n;
for(int i=0; i<n; i++) cin >> a[i] >> b[i];
sort(a, a+n);
sort(b, b+n);
int i=n-1, j=n-1, li=-1, lj=-1;
double x=0.0, y=0.0, res=0.0;
while(i>=0 || j>=0){
if(i==li && lj==j) return 0;
li=i;
lj=j;
if(j>=0 && x>y) y+=b[j--];
else if(i>=0 )x+=a[i--];
else break;
res=max(res, min(x, y)-(n-i)-(n-j)+2);
//cout << i << " " << j << endl;
}
cout << fixed << setprecision(4) << res;
//cin.close();
//cout.close();
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... |