#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <limits.h>
using namespace std;
int main () {
int N; cin >> N;
vector<double> a(N), b(N);
for (int i = 0; i < N; i++) {
cin >> a[i] >> b[i];
}
sort(a.begin(), a.end()), reverse(a.begin(), a.end());
sort(b.begin(), b.end()), reverse(b.begin(), b.end());
vector<double> pref_a(N + 1), pref_b(N + 1);
pref_a[0] = pref_b[0] = 0;
for (int i = 1; i <= N; i++) {
pref_a[i] = pref_a[i - 1] + a[i - 1];
pref_b[i] = pref_b[i - 1] + b[i - 1];
}
double ansr = 0;
for (int i = 0; i <= N; i++) {
int l = 0;
int r = N;
while (l != r) {
int m = (l + r)/2;
if (pref_a[i] - i - m <= pref_b[m] - i - m) {
r = m;
} else {
l = m + 1;
}
}
for (int j = l; j <= N; j++) {
double ans = min(pref_a[i] - i - j, pref_b[j] - i - j);
ansr = max(ansr, ans);
}
}
printf("%.4lf",(double)ansr);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |