#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ll inf = 1e18;
const ld eps = 1e-13;
const ll mod = 1e9+7;
const int i_inf = 1e9;
const int mxn = 1e5;
mt19937 _rand(time(NULL));
clock_t timer = clock();
void solve(){
int n;
cin >> n;
ld l[n], r[n];
fr(i, 0, n){
cin >> l[i] >> r[i];
}
sort(l, l+n);
reverse(l, l+n);
sort(r, r+n);
reverse(r, r+n);
ld ans = 0;
ld sa = 0;
ld sb = 0;
int a = 0;
int b = 0;
fr(i, 1, 2*n+1){
if(a == n) sb += r[b++];
else if(b == n) sa += l[a++];
else{
if(sa < sb){
sa += l[a++];
}
else{
sb += r[b++];
}
}
ans = max(ans, min(sa, sb) - i);
}
cout<<fixed<<setprecision(10)<<ans<<endl;
}
int main(){
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |