# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
320679 |
2020-11-09T13:53:27 Z |
phathnv |
Sure Bet (CEOI17_sure) |
C++11 |
|
111 ms |
4588 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 1e5 + 1;
const double INF = 1e9;
int n;
double a[N], b[N], dp[N];
void readInput(){
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
}
void prepare(){
sort(a + 1, a + 1 + n, greater<double>());
sort(b + 1, b + 1 + n, greater<double>());
for(int i = 1; i <= n; i++){
a[i] += a[i - 1];
b[i] += b[i - 1];
}
}
void calc(int l, int r, int from, int to){
if (l > r)
return;
int mid = (l + r) >> 1;
int pos = -1;
dp[mid] = -INF;
for(int i = from; i <= to; i++)
if (dp[mid] < min(a[mid], b[i]) - (mid + i)){
dp[mid] = min(a[mid], b[i]) - (mid + i);
pos = i;
}
calc(l, mid - 1, from, pos);
calc(mid + 1, r, pos, to);
}
void solve(){
calc(1, n, 0, n);
cout << fixed << setprecision(4) << *max_element(dp, dp + 1 + n);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
readInput();
prepare();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
101 ms |
4068 KB |
Output is correct |
18 |
Correct |
89 ms |
4068 KB |
Output is correct |
19 |
Correct |
88 ms |
4196 KB |
Output is correct |
20 |
Correct |
111 ms |
4072 KB |
Output is correct |
21 |
Correct |
110 ms |
4588 KB |
Output is correct |
22 |
Correct |
88 ms |
4068 KB |
Output is correct |
23 |
Correct |
108 ms |
4028 KB |
Output is correct |
24 |
Correct |
101 ms |
4068 KB |
Output is correct |
25 |
Correct |
89 ms |
4192 KB |
Output is correct |
26 |
Correct |
100 ms |
4448 KB |
Output is correct |