답안 #65772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65772 2018-08-08T17:53:14 Z naderjemel Sure Bet (CEOI17_sure) C++14
0 / 100
3 ms 620 KB
#include <bits/stdc++.h>
using namespace std;
const long long INF=2e9;
int main(){
	int n; scanf("%d",&n);
	vector<long long> as,bs;
	for(int i=0;i<n;i++){
		double a,b; scanf("%lf %lf",&a,&b); a*=10000; b*=10000;
		long long A=a;
		long long B=b;
		as.push_back(A);
		bs.push_back(B);
	}
	sort(as.begin(),as.end());
	sort(bs.begin(),bs.end());
	reverse(as.begin(),as.end());
	reverse(bs.begin(),bs.end());
	int i=0,j=0;
	long long rs=0,us=0;
	long long nowa=0,nowb=0;
	while(i<n || j<n){
		if(i<n && j<n){
			if(nowa<=nowb && i<n){
				nowa+=as[i];
				i++; us+=10000;
			}
			else if(j<n){
				nowb+=bs[j];
				j++; us+=10000;
			}
		}
		else if(i<n){
			nowa+=as[i];
			i++; us+=10000;
		}
		else{
			nowb+=bs[j];
			j++; us+=10000;
		}
		rs=max(rs,min(nowa-us,nowb-us));
	}
	printf("%.4lf\n", (double)rs/10000.0);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:5:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d",&n);
         ~~~~~^~~~~~~~~
sure.cpp:8:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   double a,b; scanf("%lf %lf",&a,&b); a*=10000; b*=10000;
               ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Incorrect 2 ms 620 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Incorrect 2 ms 620 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Incorrect 2 ms 620 KB Output isn't correct