# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
230495 |
2020-05-10T08:36:05 Z |
islingr |
Sure Bet (CEOI17_sure) |
C++14 |
|
160 ms |
3584 KB |
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(x, v) for (auto &x : v)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
using ld = long double;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
vector<ld> a(n + 1), b(n + 1);
a[0] = b[0] = 1e6;
rep(i, 0, n) cin >> a[i + 1] >> b[i + 1];
sort(rall(a)); sort(rall(b));
a[0] = b[0] = 0;
rep(i, 0, n) a[i + 1] += a[i], b[i + 1] += b[i];
auto f = [&](int x, int y) -> ld { return min(a[x], b[y]) - x - y; };
ld ans = 0;
rep(x, 0, n + 1) {
int l = 0, r = n;
while (r - l > 4) {
int m = l + (r - l) / 2;
if (f(x, m) < f(x, m + 1)) l = m;
else r = m + 1;
}
rep(i, l, r + 1) ans = max(ans, f(x, i));
}
cout << fixed << setprecision(4) << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
149 ms |
3536 KB |
Output is correct |
18 |
Correct |
151 ms |
3584 KB |
Output is correct |
19 |
Correct |
153 ms |
3456 KB |
Output is correct |
20 |
Correct |
145 ms |
3456 KB |
Output is correct |
21 |
Correct |
160 ms |
3456 KB |
Output is correct |
22 |
Correct |
145 ms |
3456 KB |
Output is correct |
23 |
Correct |
142 ms |
3528 KB |
Output is correct |
24 |
Correct |
146 ms |
3576 KB |
Output is correct |
25 |
Correct |
146 ms |
3456 KB |
Output is correct |
26 |
Correct |
160 ms |
3576 KB |
Output is correct |