Submission #924378

# Submission time Handle Problem Language Result Execution time Memory
924378 2024-02-09T02:21:47 Z NK_ Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 348 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())

using db = double;
using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;

const int MUL = int(1e4);

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int N; cin >> N;

	vi A(N), B(N); for(int i = 0; i < N; i++) {
		db x, y; cin >> x >> y;
		A[i] = int(MUL * x), B[i] = int(MUL * y);
	}

	sort(rbegin(A), rend(A)); sort(rbegin(B), rend(B));

	ll sa = A[0], sb = B[0], ans = 0; int a = 1, b = 1;

	while(1) {
		int x = a + b;
		ans = max(ans, min(sa - x * MUL, sb - x * MUL));
		// cout << ans << " " << sa << " " << sb << " " << x << endl;

		if (sa == sb) {
			if (max(a, b) == N) break;
			sa += A[a++];
			sb += B[b++];
		} else if (sa < sb) {
			if (a == N) break;
			sa += A[a++];
		} else if (sb > sa) {
			if (b == N) break;
			sb += B[b++];
		} else break;
	}

	printf("%.4f", db(ans) / db(MUL));

	exit(0-0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -