Submission #997805

# Submission time Handle Problem Language Result Execution time Memory
997805 2024-06-12T22:55:54 Z amirhoseinfar1385 Sure Bet (CEOI17_sure) C++17
100 / 100
1208 ms 6724 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int n;
vector<long double>psa,psb,alla,allb;

void vorod(){
	cin>>n;
	alla.resize(n);
	allb.resize(n);
	for(int i=0;i<n;i++){
		cin>>alla[i]>>allb[i];
	}
}

void pre(){
	sort(allb.rbegin(),allb.rend());
	sort(alla.rbegin(),alla.rend());
	psa.resize(n);
	psb.resize(n);
	psa[0]=alla[0];
	psb[0]=allb[0];
	for(int i=1;i<n;i++){
		psa[i]=psa[i-1]+alla[i];
		psb[i]=psb[i-1]+allb[i];
	}
}

void solve(){
	long double res=0;
	for(int i=1;i<=n*2;i++){
		long double low=0,high=1000*i+1,mid;
		for(int j=0;j<50;j++){
			mid=(high+low)/2;
			mid+=i;
			int pa=lower_bound(psa.begin(),psa.end(),mid)-psa.begin();
			int pb=lower_bound(psb.begin(),psb.end(),mid)-psb.begin();
			if(pa==(int)psa.size()||pb==(int)psb.size()){
				high=mid-i;
				continue;
			}
			if(pa+pb+2<=i){
				low=mid-i;
				continue;
			}
			high=mid-i;
		}
		res=max(res,low);
	}
	cout<<setprecision(4)<<fixed<<res<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	vorod();
	pre();
	solve();
}
# 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 7 ms 528 KB Output is correct
13 Correct 8 ms 348 KB Output is correct
14 Correct 8 ms 348 KB Output is correct
15 Correct 8 ms 524 KB Output is correct
16 Correct 8 ms 496 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 7 ms 528 KB Output is correct
13 Correct 8 ms 348 KB Output is correct
14 Correct 8 ms 348 KB Output is correct
15 Correct 8 ms 524 KB Output is correct
16 Correct 8 ms 496 KB Output is correct
17 Correct 1138 ms 6676 KB Output is correct
18 Correct 1106 ms 6680 KB Output is correct
19 Correct 1111 ms 6480 KB Output is correct
20 Correct 1097 ms 6484 KB Output is correct
21 Correct 1180 ms 6724 KB Output is correct
22 Correct 1077 ms 6720 KB Output is correct
23 Correct 1118 ms 6652 KB Output is correct
24 Correct 1144 ms 6652 KB Output is correct
25 Correct 1187 ms 6724 KB Output is correct
26 Correct 1208 ms 6484 KB Output is correct