이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N_MAX = (int) 1e5;
int n;
ld a[N_MAX + 2];
ld b[N_MAX + 2];
ld f (int i, int j) {
return min(a[i] - i - j, b[j] - i - j);
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
sort(a + 1, a + n + 1, greater <ld> ());
sort(b + 1, b + n + 1, greater <ld> ());
for (int i = 1; i <= n; i++) {
a[i] += a[i - 1];
b[i] += b[i - 1];
}
ld answer = 0;
for (int i = 0, j = 0; i <= n; i++) {
while (j < n && b[j + 1] <= a[i]) {
j++;
}
answer = max(answer, f(i, j));
if (j + 1 <= n) {
answer = max(answer, f(i, j + 1));
}
}
cout << fixed << setprecision(4) << answer << "\n";
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... |