# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
289409 |
2020-09-02T16:00:40 Z |
johutha |
Sure Bet (CEOI17_sure) |
C++14 |
|
99 ms |
3832 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#define int int64_t
using namespace std;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<double> as(n);
vector<double> bs(n);
for (int i = 0; i < n; i++) cin >> as[i] >> bs[i];
sort(as.begin(), as.end()); sort(bs.begin(), bs.end());
reverse(as.begin(), as.end()); reverse(bs.begin(), bs.end());
double mx = 0;
double a = 0;
double b = 0;
int ap = 0, bp = 0;
while (ap + bp < 2*n)
{
if (a < b && ap >= n) break;
if (b < a && bp >= n) break;
if (a < b) { a += as[ap]; ap++; }
else { b += bs[bp]; bp++; }
mx = max(mx, min(a, b) - (double)(ap + bp));
}
cout << setprecision(4) << fixed;
cout << mx << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
92 ms |
3320 KB |
Output is correct |
18 |
Correct |
93 ms |
3320 KB |
Output is correct |
19 |
Correct |
92 ms |
3320 KB |
Output is correct |
20 |
Correct |
94 ms |
3324 KB |
Output is correct |
21 |
Correct |
98 ms |
3832 KB |
Output is correct |
22 |
Correct |
97 ms |
3224 KB |
Output is correct |
23 |
Correct |
96 ms |
3320 KB |
Output is correct |
24 |
Correct |
92 ms |
3352 KB |
Output is correct |
25 |
Correct |
92 ms |
3320 KB |
Output is correct |
26 |
Correct |
99 ms |
3704 KB |
Output is correct |