Submission #49321

# Submission time Handle Problem Language Result Execution time Memory
49321 2018-05-25T16:52:57 Z robert Sure Bet (CEOI17_sure) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

string padding(long long n, long long l, char c){
	string res = "";
	long long nm = pow(10, l);
	while(nm>n){
		n *=10;
		res += c;
	}
	return res;
}

int main(){
	long long N; cin>>N;
	long long a[100100], b[100100];
	long long sc = 10000;
	double f, s;
	for(long long n=0; n<N; n++){
		cin>>f>>s;
		a[n] = f*10000;
		b[n] = s*10000;
	}
	sort(a, a+N);
	sort(b, b+N);
	long long ans = 0;
	long long l = N-2, r = N-2;
	long long lo = a[N-1], ro = b[N-1];
	long long bt = 2;
	while(l>=0||r>=0){
		ans = max(ans, min(lo, ro)-bt*sc);
		if(lo==ro){
			if(l>=0&&r<0){
				lo += a[l--];
				bt++;
			} else if(l<0&&r>=0){
				ro += b[r--];
				bt++;
			} else {
				if(b[r]>a[l]){
					ro += b[r--];
					bt++;
				} else {
					lo += a[l--];
					bt++;
				}
			}
		}
		else if(lo<ro){
			if(l>=0){
				lo += a[l--];
				bt++;
			} else {
				break;
			}
		} else {
			if(r>=0){
				ro += b[r--];
				bt++;
			} else {
			
				break;
			}
		}
		ans = max(ans, min(lo, ro)-bt*sc);
	}
	double dans = ans;
	printf("%.4f\n", dans/((double)sc));
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -