답안 #891146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891146 2023-12-22T08:45:49 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 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(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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -