Submission #938295

# Submission time Handle Problem Language Result Execution time Memory
938295 2024-03-05T04:21:06 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
const long long INF=1e17,N=2e5+6;
main(){
	int n;cin>>n;
	vector<long double> a(n),b(n);
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	sort(a.rbegin(),a.rend());
	sort(b.rbegin(),b.rend());
	long double ans=0,A=0,B=0;
	int l=1,r=1;
	A+=a[0],B+=b[0];
	ans=min(A-2,B-2);
	while(l<n || r<n){
		if(l<n && r<n){
			if(A<B)
				A+=a[l++];
			else
				B+=b[r++];
		}
		else if(l<n)
			A+=a[l++];
		else
			B+=b[r++];
		ans=max(ans,min(A-l-r,B-l-r));
	}
	cout<<fixed<<setprecision(6)<<ans<<endl;
}
/*
5 1
lkjhg
polir
*/

Compilation message

sure.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -