Submission #891143

# Submission time Handle Problem Language Result Execution time Memory
891143 2023-12-22T08:43:11 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

//#pragma comment(linker, "/stack:2000000000")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define x first
#define y second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pf push_front
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()

void boost(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	return;
}

//ull binpow(ull p, int i){
//	if(i==0) return 1;
//	else if(i==1) return p;
//	else if(i%2==0) return binpow(p*p,i/2);
//	else return binpow(p*p,i/2)*p;
//}

void solve(){
	int n;
	cin>>n;
	ld a[n],b[n];
	for(int i=0; i<n; i++) cin>>a[i]>>b[i];
	sort(a,a+n,greater<double>());
	sort(b,b+n,greater<double>());
	ld ans=0;
	int p1=1,p2=1;
	ld suma=a[0],sumb=b[0];
	while(p1<n||p2<n){
		if(p1==n||p2==n){
			if(p1==n){
				sumb+=b[p2];
				p2++;
			}
			else{
				suma+=a[p1];
				p1++;
			}
		}
		else{
			if(suma>sumb){
				sumb+=b[p2];
				p2++;
			}
			else{
				suma+=a[p1];
				p1++;
			}
		}
		ans=max(ans,min(suma,sumb)-p1-p2);
	}
	cout<<setprecision(15)<<ans;
	return;
}

int main(){
	boost();
	int t=1;
//	cin>>t;
	while(t--) solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -