# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1027547 |
2024-07-19T07:27:23 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
1 ms |
4440 KB |
#include <bits/stdc++.h>
using namespace std;
#define ld long double
const int N = 1e5+5;
int n;
ld a[N], b[N], sufB[N];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cout << fixed << setprecision(10);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
sort(a, a+n);
sort(b, b+n);
sufB[n] = 0;
for (int i = n-1; i >= 0; i--) {
sufB[i] = sufB[i+1] + b[i];
}
ld ans = 0;
ld sumA = 0;
for (int i = n-1; i >= 0; i--) {
sumA += a[i];
int l = 0;
int r = n-1;
while (l < r) {
int mid = (l+r) >> 1;
if (sufB[mid] >= sumA) l = mid+1;
else r = mid;
}
ans = max(ans, min(sumA, sufB[l]) - (n-i) - (n-l));
if (l-1 >= 0) ans = max(ans, min(sumA, sufB[l-1]) - (n-i) - (n-l+1));
if (l-2 >= 0) ans = max(ans, min(sumA, sufB[l-2]) - (n-i) - (n-l+2));
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |