답안 #701082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701082 2023-02-20T04:04:30 Z Darren0724 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define all(x) x.begin(),x.end()
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	vector<double> a(n+1),b(n+1);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	a[n]=0;
	b[n]=0;
	sort(all(a),greater<>());
	sort(all(b),greater<>());
	double total1=0,total2=0;
	int ptr1=0,ptr2=0;
	double ans=0;
	for(;ptr1<n&&ptr2<n;){
		if(total1<total2||ptr2==n){
			total1+=a[ptr1++];
		}
		else{
			total2+=b[ptr2++];
		}
		total1-=1;
		total2-=1;
		ans=max(min(total1,total2),ans);
	}
	cout<<fixed<<setprecision(4)<<ans<<endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -