제출 #63154

#제출 시각아이디문제언어결과실행 시간메모리
63154khsoo01Sure Bet (CEOI17_sure)C++11
100 / 100
142 ms4412 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;

int n;
double a[N], b[N];

bool can (double P) {
	double pa = 0, pb = 0;
	int i = n, j = n;
	while(true) {
		bool upd = false;
		while(i >= 1 && pa < P) {
			pa -= 1.0; pb -= 1.0;
			pa += a[i]; i--;
			upd = true;
		}
		while(j >= 1 && pb < P) {
			pa -= 1.0; pb -= 1.0;
			pb += b[j]; j--;
			upd = true;
		}
		if(!upd) break;
	}
	if(pa >= P && pb >= P) return true;
	return false;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%lf%lf",&a[i],&b[i]);
	}
	sort(a+1, a+1+n);
	sort(b+1, b+1+n);
	double S = 0, E = 2e9;
	for(int i=0;i<50;i++) {
		double M = (S+E)/2;
		can(M) ? S = M : E = M;
	}
	printf("%.4f\n",S);
}

컴파일 시 표준 에러 (stderr) 메시지

sure.cpp: In function 'int main()':
sure.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
sure.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf%lf",&a[i],&b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...