답안 #607466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
607466 2022-07-26T17:57:05 Z UncoolAnon Sure Bet (CEOI17_sure) C++14
100 / 100
266 ms 6016 KB
#include <bits/stdc++.h> 
#define double long double 
using namespace std; 
const double eps=0.00001; 
int main(){
	int n; 
	cin>>n; 
	vector<double> a(n),b(n); 
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]; 
	double answer=0; 
	vector<int> A,B; 
	for(int i=0;i<n;i++){
		if(a[i]<1&&b[i]<1){}
		else{
			A.push_back(i); 
			B.push_back(i); 
		}
	}
	sort(A.begin(),A.end(),[&](int i,int j){
		if(a[i]==a[j]) return b[i]>b[j]; 
		return a[i]>a[j]; 
	}); 
	sort(B.begin(),B.end(),[&](int i,int j){
		if(b[i]==b[j]) return a[i]>a[j]; 
		return b[i]>b[j]; 
	}); 
	double curB=0; 
    n=B.size(); 
	vector<double> p(n); 
	for(int i=0;i<n;i++){
		curB+=b[B[i]]; 
		p[i]=curB-i-1; 
		if(i) p[i]=max(p[i-1],p[i]); 
	}
	double curA=0; 
	for(int i=0;i<n;i++){
		curA+=a[A[i]]; 
		double l=0,r=2e8+1;
		while(r-l>eps){
			double md=(r+l)/2; 
			int j=curA-i-1-md; 
			j=min(j,n); 
			if(j>=1&&p[j-1]-md>=i+1) l=md; 
			else r=md; 
		}
		answer=max(answer,l); 
	}
	cout<<fixed<<setprecision(4)<<answer; 
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 226 ms 6004 KB Output is correct
18 Correct 247 ms 6016 KB Output is correct
19 Correct 236 ms 5952 KB Output is correct
20 Correct 215 ms 6000 KB Output is correct
21 Correct 263 ms 6012 KB Output is correct
22 Correct 230 ms 5996 KB Output is correct
23 Correct 219 ms 5996 KB Output is correct
24 Correct 263 ms 5976 KB Output is correct
25 Correct 232 ms 6000 KB Output is correct
26 Correct 266 ms 6000 KB Output is correct