# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1028447 |
2024-07-19T22:11:44 Z |
sopaconk |
Sure Bet (CEOI17_sure) |
C++17 |
|
69 ms |
5244 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using lli=long long int;
using ld=long double;
void solve(){
lli n=1;
// deb(n);
cin>>n;
// deb(n);
vector<ld> v1(n);
vector<ld> v2(n);
for(lli i=0; i<n; ++i){
cin>>v1[i]>>v2[i];
// deb(v1[i]);
// deb(v2[i]);
}
sort(v1.rbegin(), v1.rend());
sort(v2.rbegin(), v2.rend());
ld ans=0;
ld aux=0;
ld a=0;
ld b=0;
lli p1=0;
lli p2=0;
while(p1<n || p2<n){
if(a<=b){
if(p1<n){
a+=v1[p1];
p1++;
}
else{
b+=v2[p2];
p2++;
}
}
else{
if(p2<n){
b+=v2[p2];
p2++;
}
else{
a+=v1[p1];
p1++;
}
}
// deb(a);
// deb(b);
aux=min(a,b);
aux-=(p1+p2);
// deb(aux);
ans=max(ans, aux);
}
cout<<setprecision(4)<<fixed<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
lli t=1;
//cin>>t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 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 |
1 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 |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 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 |
1 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 |
468 KB |
Output is correct |
17 |
Correct |
59 ms |
4948 KB |
Output is correct |
18 |
Correct |
60 ms |
4944 KB |
Output is correct |
19 |
Correct |
59 ms |
4948 KB |
Output is correct |
20 |
Correct |
58 ms |
4956 KB |
Output is correct |
21 |
Correct |
69 ms |
5200 KB |
Output is correct |
22 |
Correct |
60 ms |
4956 KB |
Output is correct |
23 |
Correct |
59 ms |
4956 KB |
Output is correct |
24 |
Correct |
58 ms |
4956 KB |
Output is correct |
25 |
Correct |
58 ms |
4956 KB |
Output is correct |
26 |
Correct |
64 ms |
5244 KB |
Output is correct |