# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
904003 |
2024-01-11T16:45:43 Z |
Dec0Dedd |
Sure Bet (CEOI17_sure) |
C++14 |
|
101 ms |
6844 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int N = 1e5+10;
const int K = 1e4;
ld a[N], b[N], p[N];
ll n;
ld genx() {
ld x=0, sm=0;
for (ll i=1; i<=n; ++i) {
sm+=a[i];
ll lf=0, rf=n, res=0;
while (lf <= rf) {
ll m=(lf+rf)/2;
if (sm-m >= p[m]-i) lf=m+1, res=m;
else rf=m-1;
}
ld val=max(min(sm-res, p[res]-i), min(sm-(res+1), p[res+1]-i));
x=max(x, val);
} return x;
}
void solve() {
cin>>n;
for (int i=1; i<=n; ++i) {
cin>>a[i]>>b[i]; --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+1; ++i) p[i]=p[i-1]+b[i];
ld ans=genx();
swap(a, b);
p[0]=0;
for (int i=1; i<=n+1; ++i) p[i]=p[i-1]+b[i];
ans=max(ans, genx());
printf("%.4lf", (double)ans);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
while (t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
4816 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
4956 KB |
Output is correct |
12 |
Correct |
2 ms |
4952 KB |
Output is correct |
13 |
Correct |
3 ms |
4956 KB |
Output is correct |
14 |
Correct |
3 ms |
4956 KB |
Output is correct |
15 |
Correct |
3 ms |
4956 KB |
Output is correct |
16 |
Correct |
3 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
4816 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
4956 KB |
Output is correct |
12 |
Correct |
2 ms |
4952 KB |
Output is correct |
13 |
Correct |
3 ms |
4956 KB |
Output is correct |
14 |
Correct |
3 ms |
4956 KB |
Output is correct |
15 |
Correct |
3 ms |
4956 KB |
Output is correct |
16 |
Correct |
3 ms |
4956 KB |
Output is correct |
17 |
Correct |
100 ms |
6332 KB |
Output is correct |
18 |
Correct |
89 ms |
6340 KB |
Output is correct |
19 |
Correct |
85 ms |
6480 KB |
Output is correct |
20 |
Correct |
83 ms |
6484 KB |
Output is correct |
21 |
Correct |
101 ms |
6712 KB |
Output is correct |
22 |
Correct |
83 ms |
6472 KB |
Output is correct |
23 |
Correct |
101 ms |
6512 KB |
Output is correct |
24 |
Correct |
84 ms |
6416 KB |
Output is correct |
25 |
Correct |
86 ms |
6464 KB |
Output is correct |
26 |
Correct |
87 ms |
6844 KB |
Output is correct |