# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
340196 |
2020-12-27T09:20:43 Z |
blue |
Sure Bet (CEOI17_sure) |
C++11 |
|
187 ms |
3692 KB |
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
/*
a[i] >= a[i+1]
b[i] >= b[i+1]
To maximise: min(a[1] + ... + a[i], b[1] + ... + b[j]) - (i + j)
*/
int main()
{
int n;
cin >> n;
double a[n], b[n];
for(int i = 0; i < n; i++)
{
cin >> a[i] >> b[i];
a[i] = -1.0 * a[i];
b[i] = -1.0 * b[i];
}
sort(a, a+n);
sort(b, b+n);
double res = 0.0;
int A = 0, B = 0;
double asum = 0.0, bsum = 0.0;
while(A+B < 2*n)
{
if(A == n)
{
bsum -= b[B];
B++;
}
else if(B == n)
{
asum -= a[A];
A++;
}
else if(asum == bsum)
{
if(-a[A] > -b[B])
{
asum -= a[A];
A++;
}
else
{
bsum -= b[B];
B++;
}
}
else if(asum > bsum)
{
bsum -= b[B];
B++;
}
else
{
asum -= a[A];
A++;
}
res = max(res, min(asum, bsum) - double(A+B));
}
printf("%.4lf",(double)res);
}
# |
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 |
440 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 |
440 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 |
440 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 |
142 ms |
3208 KB |
Output is correct |
18 |
Correct |
140 ms |
3192 KB |
Output is correct |
19 |
Correct |
150 ms |
3308 KB |
Output is correct |
20 |
Correct |
156 ms |
3308 KB |
Output is correct |
21 |
Correct |
187 ms |
3692 KB |
Output is correct |
22 |
Correct |
139 ms |
3304 KB |
Output is correct |
23 |
Correct |
144 ms |
3308 KB |
Output is correct |
24 |
Correct |
141 ms |
3380 KB |
Output is correct |
25 |
Correct |
140 ms |
3308 KB |
Output is correct |
26 |
Correct |
158 ms |
3564 KB |
Output is correct |