# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
197403 |
2020-01-21T03:37:15 Z |
Juney |
Sure Bet (CEOI17_sure) |
C++14 |
|
106 ms |
3756 KB |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5 + 5;
int N;
double A[MAXN], B[MAXN], ans;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> N;
for(int i=1; i<=N; i++) cin >> A[i] >> B[i];
sort(A+1, A+1+N, greater<double>()); sort(B+1, B+1+N, greater<double>());
int a = 0, b = 0;
double sum1 = 0, sum2 = 0;
for(int i=1; i<=2*N; i++) {
if(a == N) sum2 += B[++b];
else if(b == N) sum1 += A[++a];
else {
if(sum1 < sum2) sum1 += A[++a];
else sum2 += B[++b];
}
ans = max(ans, min(sum1, sum2) - i);
}
printf("%.4lf", ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
504 KB |
Output is correct |
16 |
Correct |
3 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
504 KB |
Output is correct |
16 |
Correct |
3 ms |
380 KB |
Output is correct |
17 |
Correct |
98 ms |
3292 KB |
Output is correct |
18 |
Correct |
97 ms |
3440 KB |
Output is correct |
19 |
Correct |
97 ms |
3320 KB |
Output is correct |
20 |
Correct |
97 ms |
3320 KB |
Output is correct |
21 |
Correct |
104 ms |
3756 KB |
Output is correct |
22 |
Correct |
96 ms |
3320 KB |
Output is correct |
23 |
Correct |
96 ms |
3320 KB |
Output is correct |
24 |
Correct |
95 ms |
3448 KB |
Output is correct |
25 |
Correct |
97 ms |
3320 KB |
Output is correct |
26 |
Correct |
106 ms |
3704 KB |
Output is correct |