# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
722308 |
2023-04-11T18:04:34 Z |
Pety |
Sure Bet (CEOI17_sure) |
C++14 |
|
98 ms |
3584 KB |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("gadfadar2.in");
ofstream fout ("gadfadar2.out");
int n;
double a[100002], b[100002];
double f (int na, int nb) {
return min(a[na] - nb, b[nb] - na);
}
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];
a[i] -= 1.0;
b[i] -= 1.0;
}
sort(a + 1, a + n + 1, greater<double>());
sort(b + 1, b + n + 1, greater<double>());
for (int i = 1; i <= n; i++)
a[i] += a[i - 1];
for (int i = 1; i <= n; i++)
b[i] += b[i - 1];
double ans = -1e9;
for (int i = 0; i <= n; i++) {
double val = a[i];
int st = 0, dr = n - 1, p = -1;
while (st <= dr) {
int mid = (st + dr) / 2;
if (f(i, mid) < f(i, mid + 1)) {
p = mid;
st = mid + 1;
}
else
dr = mid - 1;
}
ans = max(ans, f(i, p + 1));
}
cout << fixed << setprecision(4) << ans;
return 0;
}
Compilation message
sure.cpp: In function 'int main()':
sure.cpp:33:12: warning: unused variable 'val' [-Wunused-variable]
33 | double val = a[i];
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 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 |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
83 ms |
3264 KB |
Output is correct |
18 |
Correct |
78 ms |
3156 KB |
Output is correct |
19 |
Correct |
79 ms |
3300 KB |
Output is correct |
20 |
Correct |
80 ms |
3136 KB |
Output is correct |
21 |
Correct |
85 ms |
3584 KB |
Output is correct |
22 |
Correct |
98 ms |
3204 KB |
Output is correct |
23 |
Correct |
74 ms |
3148 KB |
Output is correct |
24 |
Correct |
76 ms |
3248 KB |
Output is correct |
25 |
Correct |
78 ms |
3264 KB |
Output is correct |
26 |
Correct |
88 ms |
3532 KB |
Output is correct |