답안 #607449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
607449 2022-07-26T17:41:31 Z UncoolAnon Sure Bet (CEOI17_sure) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h> 
#define double long double 
using namespace std; 
const double eps=0.000001; 
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=1+5;
		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); 
	}
	printf("%.4lf",(double)answer);
	return 0; 
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:48:14: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat=]
   48 |  printf("%.4lf",(double)answer);
      |          ~~~~^  ~~~~~~~~~~~~~~
      |              |  |
      |              |  long double
      |              double
      |          %.4Lf
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -