답안 #938296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938296 2024-03-05T04:23:07 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 600 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(4)<<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(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -