Submission #891161

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

#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;
}

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 cnt1=1,cnt2=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++;
				cnt2++;
			}
			else{
				suma+=a[p1];
				p1++;
				cnt1++;
			}
		}
		else{
			if(suma>sumb){
				sumb+=b[p2];
				p2++;
				cnt2++;
			}
			else{
				suma+=a[p1];
				p1++;
				cnt1++;
			}
		}
		ans=max(ans,min(suma,sumb)-cnt1-cnt2);
	}
	cout<<setprecision(4)<<ans;
	return;
}

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