#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5 + 5;
int N;
double A[MAXN], B[MAXN], ans = -1e9;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> N;
for(int i=1; i<=N; i++) cin >> A[i] >> B[i];
sort(A+1, A+1+N, greater<double>()); sort(B+1, B+1+N, greater<double>());
int a = 0, b = 0;
double sum1 = 0, sum2 = 0;
for(int i=1; i<=2*N; i++) {
if(a == N) sum2 += B[++b];
else if(b == N) sum1 += A[++a];
else {
if(sum1 < sum2) sum1 += A[++a];
else sum2 += B[++b];
}
ans = max(ans, min(sum1, sum2) - i);
}
printf("%.4lf", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |