# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
120091 |
2019-06-23T08:57:58 Z |
MB81 |
Sure Bet (CEOI17_sure) |
C++14 |
|
1428 ms |
5304 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;
double s1[maxn], s2[maxn];
double a[maxn], b[maxn];
int n;
int g1 (double x) {
if (s1[n - 1] < x)
return n;
int l = -1, r = n - 1, mid;
while (r - l > 1) {
mid = (l + r) >> 1;
if (s1[mid] >= x)
r = mid;
else
l = mid;
}
return r;
}
int g2 (double x) {
if (s2[n - 1] < x)
return n;
int l = -1, r = n - 1, mid;
while (r - l > 1) {
mid = (l + r) >> 1;
if (s2[mid] >= x)
r = mid;
else
l = mid;
}
return r;
}
int main () {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
sort(a, a + n); reverse(a, a + n);
sort(b, b + n); reverse(b, b + n);
s1[0] = a[0];
s2[0] = b[0];
for (int i = 1; i < n; i++) {
s1[i] = s1[i - 1] + a[i];
s2[i] = s2[i - 1] + b[i];
}
double ans = 0;
for (int i = 1; i <= 2 * n; i++) {
double l = 0, r = IN, mid;
for (int j = 0; j < 50; j++) {
mid = (l + r) / 2;
int p1 = g1(mid), p2 = g2(mid);
if (p1 == n || p2 == n || p1 + 1 + p2 + 1 > i)
r = mid;
else
l = mid;
}
ans = max(ans, l - i);
}
cout << fixed << setprecision(4) << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
13 |
Correct |
7 ms |
356 KB |
Output is correct |
14 |
Correct |
8 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
384 KB |
Output is correct |
16 |
Correct |
8 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
13 |
Correct |
7 ms |
356 KB |
Output is correct |
14 |
Correct |
8 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
384 KB |
Output is correct |
16 |
Correct |
8 ms |
384 KB |
Output is correct |
17 |
Correct |
1144 ms |
3552 KB |
Output is correct |
18 |
Correct |
1156 ms |
4860 KB |
Output is correct |
19 |
Correct |
1187 ms |
4856 KB |
Output is correct |
20 |
Correct |
1127 ms |
4856 KB |
Output is correct |
21 |
Correct |
1428 ms |
5304 KB |
Output is correct |
22 |
Correct |
1187 ms |
4956 KB |
Output is correct |
23 |
Correct |
1177 ms |
4956 KB |
Output is correct |
24 |
Correct |
1166 ms |
4984 KB |
Output is correct |
25 |
Correct |
1130 ms |
4900 KB |
Output is correct |
26 |
Correct |
1405 ms |
5292 KB |
Output is correct |