# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
299012 |
2020-09-14T12:13:19 Z |
istlemin |
Sure Bet (CEOI17_sure) |
C++14 |
|
250 ms |
2432 KB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i = a; i<ll(b); i++)
#define trav(x,s) for(auto &x: s)
#define all(v) v.begin(),v.end()
#define sz(v) ll(v.size())
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
int main(){
ll n;
cin>>n;
vector<double> a(n);
vector<double> b(n);
rep(i,0,n) cin>>a[i]>>b[i];
sort(all(a));
reverse(all(a));
sort(all(b));
reverse(all(b));
ll ia = 0;
ll ib = 0;
double sa = 0;
double sb = 0;
double ans = 0;
while(true){
if(sb<sa && ib<n){
sb += b[ib];
ib++;
//cout<<"sb: "<<sb<<endl;
} else if(ia<n){
sa += a[ia];
ia++;
//cout<<"sa: "<<sa<<endl;
} else {
//cout<<"breaking"<<endl;
break;
}
//cout<<ia<<" "<<ib<<endl;
//cout<<min(sb,sa)-ia-ib<<endl;
ans = max(ans,min(sb,sa)-ia-ib);
}
printf("%.4lf\n",(double)ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
218 ms |
2304 KB |
Output is correct |
18 |
Correct |
212 ms |
2432 KB |
Output is correct |
19 |
Correct |
217 ms |
2424 KB |
Output is correct |
20 |
Correct |
217 ms |
2424 KB |
Output is correct |
21 |
Correct |
250 ms |
2424 KB |
Output is correct |
22 |
Correct |
212 ms |
2040 KB |
Output is correct |
23 |
Correct |
216 ms |
1920 KB |
Output is correct |
24 |
Correct |
216 ms |
1920 KB |
Output is correct |
25 |
Correct |
217 ms |
1944 KB |
Output is correct |
26 |
Correct |
243 ms |
1920 KB |
Output is correct |