Submission #51703

# Submission time Handle Problem Language Result Execution time Memory
51703 2018-06-20T06:51:47 Z tmwilliamlin168 Sure Bet (CEOI17_sure) C++14
20 / 100
3 ms 664 KB
#include <bits/stdc++.h>
using namespace std;

#define getchar_unlocked getchar
#define putchar_unlocked putchar

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() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	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('.');
	for(int i=0; i<4; ++i) {
		ans*=10;
		putchar_unlocked((int)ans%10+'0');
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 664 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 3 ms 664 KB Output is correct
14 Correct 2 ms 664 KB Output is correct
15 Correct 3 ms 664 KB Output is correct
16 Incorrect 3 ms 664 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 664 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 3 ms 664 KB Output is correct
14 Correct 2 ms 664 KB Output is correct
15 Correct 3 ms 664 KB Output is correct
16 Incorrect 3 ms 664 KB Output isn't correct