Submission #412448

# Submission time Handle Problem Language Result Execution time Memory
412448 2021-05-26T22:20:26 Z Pbezz Sure Bet (CEOI17_sure) C++14
100 / 100
99 ms 3504 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
 
typedef tree<pii ,null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ll MAXN = 301;
const ll MOD = 1e9+7;
const ll INF = 1e6+10;




int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,i,x,y;
	double sx,sy,ans=0;
	cin>>n;

	double a[n],b[n];
	for(i=0;i<n;i++){
	cin>>a[i]>>b[i];
	}

	sort(a,a+n,greater<double>());
	sort(b,b+n,greater<double>());

	x=0; y=0; sx=0; sy=0;

	for(i=0;i<2*n;i++){

	if((sx<=sy && x!=n)||(y==n)){
	sx+=a[x];
	x++;
	}else{
	sy+=b[y];
	y++;
	}
	//cout<<x<<" "<<y<<" "<<sx<<" "<<sy<<"  "<<(double)(min(sx,sy)-(double)(x+y))<<endl;
	ans = max(ans, (double)(min(sx,sy)-(double)(x+y)) );

}

	//cout<<setprecision(5)<<ans<<endl;
printf("%.4lf",(double)ans);



return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 87 ms 3224 KB Output is correct
18 Correct 88 ms 3136 KB Output is correct
19 Correct 85 ms 3200 KB Output is correct
20 Correct 84 ms 3128 KB Output is correct
21 Correct 99 ms 3504 KB Output is correct
22 Correct 84 ms 3124 KB Output is correct
23 Correct 83 ms 3120 KB Output is correct
24 Correct 84 ms 3144 KB Output is correct
25 Correct 83 ms 3144 KB Output is correct
26 Correct 92 ms 3504 KB Output is correct