Submission #1252937

#TimeUsernameProblemLanguageResultExecution timeMemory
1252937kaiboySure Bet (CEOI17_sure)C++20
100 / 100
42 ms1096 KiB
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

const int N = 100000;

int aa[N], bb[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		double a, b; cin >> a >> b;
		aa[i] = round(a * 10000);
		bb[i] = round(b * 10000);
	}
	sort(aa, aa + n, greater<>());
	sort(bb, bb + n, greater<>());
	long long ans = 0, s = 0, t = 0;
	for (int i = 0, j = 0; i < n || j < n; ) {
		if (i < n && (j == n || s < t))
			s += aa[i++];
		else
			t += bb[j++];
		ans = max(ans, min(s, t) - (i + j) * 10000);
	}
	printf("%d.%04d\n", (int) (ans / 10000), (int) (ans % 10000));
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...