# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1015800 |
2024-07-06T20:17:18 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
81 ms |
3736 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n; cin>>n;
vector<double> a(n),b(n);
for (int i=0; i<n; i++) cin>>a[i]>>b[i];
sort(a.begin(),a.end(),greater<double>());
sort(b.begin(),b.end(),greater<double>());
//now take prefix sums
for (int i=1; i<n; i++){
a[i]=a[i-1]+a[i];
}
for (int i=1; i<n; i++){
b[i]=b[i-1]+b[i];
}
double ans=0;
int r=0;
for (int i=0; i<n; i++){
while (r<n and b[r]<a[i]) r++;
if (r>=n) break;
ans=max(ans, a[i]-(i+1+r+1));
}
r=0;
for (int i=0; i<n; i++){
while (r<n and a[r]<b[i]) r++;
if (r>=n) break;
ans=max(ans, b[i]-(i+1+r+1));
}
printf("%.4lf",(double)ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
74 ms |
3272 KB |
Output is correct |
18 |
Correct |
72 ms |
3128 KB |
Output is correct |
19 |
Correct |
78 ms |
3256 KB |
Output is correct |
20 |
Correct |
71 ms |
3156 KB |
Output is correct |
21 |
Correct |
75 ms |
3736 KB |
Output is correct |
22 |
Correct |
72 ms |
3156 KB |
Output is correct |
23 |
Correct |
73 ms |
3152 KB |
Output is correct |
24 |
Correct |
72 ms |
3360 KB |
Output is correct |
25 |
Correct |
68 ms |
3156 KB |
Output is correct |
26 |
Correct |
81 ms |
3652 KB |
Output is correct |