#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 5e5 + 2;
const int mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
vector<ld> a(n), b(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
for (int i = 1; i < n; i++) a[i] += a[i - 1];
for (int i = 1; i < n; i++) b[i] += b[i - 1];
for (ld i : a) cout << i << sp;
cout << en;
for (ld i : b) cout << i << sp;
cout << en;
ld ans = 0;
for (int rep = 0; rep < 2; rep++) {
int j = 0;
for (int i = 0; i < n; i++) {
while (j < n && b[j] < a[i]) j++;
if (j < n) smax(ans, a[i] - i - j - 2);
}
swap(a, b);
}
cout << fixed << showpoint << setprecision(4) << ans << en;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |