답안 #51705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51705 2018-06-20T06:56:12 Z tmwilliamlin168 Sure Bet (CEOI17_sure) C++14
100 / 100
32 ms 2280 KB
#include <bits/stdc++.h>
using namespace std;

inline double in() {
	double result=0, d=1;
	char ch = getchar_unlocked();
	while(true) {
		if(ch >= '0' && ch <= '9')
			break;
		ch = getchar_unlocked();
	}
	result = ch-'0';
	while(true) {
		ch = getchar_unlocked();
		if (ch < '0' || ch > '9')
			break;
		result = result*10 + (ch - '0');
	}
	if(ch=='.') {
		while(true) {
			ch = getchar_unlocked();
			if (ch < '0' || ch > '9')
				break;
			result += (ch - '0')/(d*=10);
		}
	}
	return result;
}
inline void out(int x) {
	int rev=x, c=0;
	if(!x) {
		putchar_unlocked('0');
		return;
	}
	while(!(rev%10)) {
		++c;
		rev/=10;
	}
	rev=0;
	while(x) {
		rev=rev*10+x%10;
		x/=10;
	}
	while(rev) {
		putchar_unlocked(rev%10+'0');
		rev/=10;
	}
	while(c--)
		putchar_unlocked('0');
}

const int mxN=1e5;
int n;
double a[mxN+1], b[mxN+1], ans, sa, sb;

int main() {
	n=in();
	for(int i=0; i<n; ++i)
		a[i]=in(), b[i]=in();
	sort(a, a+n+1);
	sort(b, b+n+1);
	for(int i1=n, i2=n; i1>=0&&i2>=0; ) {
		if(sa<sb)
			sa+=a[i1--];
		else
			sb+=b[i2--];
		ans=max(min(sa, sb)-(n-i1)-(n-i2), ans);
	}
	ans+=0.00005;
	out(ans);
	putchar_unlocked('.');
	ans=ans-(int)ans;
	for(int i=0; i<4; ++i) {
		ans*=10;
		putchar_unlocked((int)ans%10+'0');
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 3 ms 712 KB Output is correct
9 Correct 3 ms 712 KB Output is correct
10 Correct 3 ms 712 KB Output is correct
11 Correct 2 ms 712 KB Output is correct
12 Correct 3 ms 712 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 712 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 3 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 3 ms 712 KB Output is correct
9 Correct 3 ms 712 KB Output is correct
10 Correct 3 ms 712 KB Output is correct
11 Correct 2 ms 712 KB Output is correct
12 Correct 3 ms 712 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 712 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 3 ms 760 KB Output is correct
17 Correct 31 ms 2184 KB Output is correct
18 Correct 26 ms 2184 KB Output is correct
19 Correct 28 ms 2184 KB Output is correct
20 Correct 26 ms 2184 KB Output is correct
21 Correct 32 ms 2184 KB Output is correct
22 Correct 30 ms 2184 KB Output is correct
23 Correct 26 ms 2280 KB Output is correct
24 Correct 31 ms 2280 KB Output is correct
25 Correct 27 ms 2280 KB Output is correct
26 Correct 27 ms 2280 KB Output is correct