# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938298 |
2024-03-05T04:24:08 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
137 ms |
3664 KB |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
const long long INF=1e17,N=2e5+6;
main(){
int n;cin>>n;
vector<long double> a(n),b(n);
for(int i=0;i<n;i++)
cin>>a[i]>>b[i];
sort(a.rbegin(),a.rend());
sort(b.rbegin(),b.rend());
long double ans=0,A=0,B=0;
int l=1,r=1;
A+=a[0],B+=b[0];
ans=max(ans,min(A-2,B-2));
while(l<n || r<n){
if(l<n && r<n){
if(A<B)
A+=a[l++];
else
B+=b[r++];
}
else if(l<n)
A+=a[l++];
else
B+=b[r++];
ans=max(ans,min(A-l-r,B-l-r));
}
cout<<fixed<<setprecision(4)<<ans<<endl;
}
/*
5 1
lkjhg
polir
*/
Compilation message
sure.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
356 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 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 |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
356 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 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 |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
101 ms |
3564 KB |
Output is correct |
18 |
Correct |
102 ms |
3420 KB |
Output is correct |
19 |
Correct |
137 ms |
3560 KB |
Output is correct |
20 |
Correct |
102 ms |
3560 KB |
Output is correct |
21 |
Correct |
118 ms |
3420 KB |
Output is correct |
22 |
Correct |
101 ms |
3564 KB |
Output is correct |
23 |
Correct |
101 ms |
3420 KB |
Output is correct |
24 |
Correct |
106 ms |
3420 KB |
Output is correct |
25 |
Correct |
109 ms |
3420 KB |
Output is correct |
26 |
Correct |
124 ms |
3664 KB |
Output is correct |