# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
543255 |
2022-03-30T01:30:19 Z |
Olympia |
Sure Bet (CEOI17_sure) |
C++17 |
|
160 ms |
4296 KB |
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <limits.h>
using namespace std;
int main () {
int N; cin >> N;
vector<double> a(N), b(N);
for (int i = 0; i < N; i++) {
cin >> a[i] >> b[i];
}
sort(a.begin(), a.end()), reverse(a.begin(), a.end());
sort(b.begin(), b.end()), reverse(b.begin(), b.end());
vector<double> pref_a(N + 1), pref_b(N + 1), min_b(N + 1);
pref_a[0] = pref_b[0] = min_b[0] = 0;
for (int i = 1; i <= N; i++) {
pref_a[i] = pref_a[i - 1] + a[i - 1];
pref_b[i] = pref_b[i - 1] + b[i - 1];
min_b[i] = max(pref_b[i] - i, min_b[i - 1]);
}
double ansr = 0;
for (int i = 0; i <= N; i++) {
int l = 0;
int r = N;
while (l != r) {
int m = (l + r)/2;
if (pref_a[i] - i - m <= pref_b[m] - i - m) {
r = m;
} else {
l = m + 1;
}
}
ansr = max(ansr, min(pref_a[i] - i - l, pref_b[l] - i - l));
if (l != 0) {
ansr = max(ansr, min_b[l - 1] - i);
}
}
printf("%.4lf",(double)ansr);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
132 ms |
4160 KB |
Output is correct |
18 |
Correct |
136 ms |
4164 KB |
Output is correct |
19 |
Correct |
149 ms |
4160 KB |
Output is correct |
20 |
Correct |
156 ms |
4168 KB |
Output is correct |
21 |
Correct |
160 ms |
4164 KB |
Output is correct |
22 |
Correct |
128 ms |
4168 KB |
Output is correct |
23 |
Correct |
133 ms |
4168 KB |
Output is correct |
24 |
Correct |
130 ms |
4172 KB |
Output is correct |
25 |
Correct |
135 ms |
4296 KB |
Output is correct |
26 |
Correct |
156 ms |
4168 KB |
Output is correct |