Submission #924689

# Submission time Handle Problem Language Result Execution time Memory
924689 2024-02-09T13:13:25 Z NK_ Sure Bet (CEOI17_sure) C++17
100 / 100
83 ms 3804 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 vd = V<db>;

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

	int N; cin >> N;

	vd A(N), B(N); for(int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

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

	for(int i = 1; i < N; i++) A[i] += A[i - 1];
	for(int i = 1; i < N; i++) B[i] += B[i - 1];

	// for(auto& x : A) cout << x << " ";
	// cout << endl;

	// for(auto& x : B) cout << x << " ";
	// cout << endl;

	db ans = 0;
	for(int x = 2; x <= 2 * N; x++) {
		// cout << x << " ===> " << endl;
		// take x odds	

		auto F = [&](int i) {
			if (i <= 0) return db(0);
			if (x - i <= 0) return db(0);
			return min(A[i - 1], B[x - 1 - i]) - x;
		};

		int lo = max(1, x - N), hi = min(x - 1, N);
		while(lo < hi) {
			int mid = (lo + hi + 1) / 2;
			if (A[mid - 1] < B[x - 1 - mid]) lo = mid;
			else hi = mid - 1;
		}

		ans = max(ans, F(lo - 1));
		ans = max(ans, F(lo));
		ans = max(ans, F(lo + 1));

		// maximize min_{1 <= i <= x}(A[i - 1] - x, B[x - i] - x)
	} 

	printf("%.4lf", ans);

	exit(0-0);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 448 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 448 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 72 ms 3152 KB Output is correct
18 Correct 74 ms 3164 KB Output is correct
19 Correct 73 ms 3384 KB Output is correct
20 Correct 74 ms 3380 KB Output is correct
21 Correct 83 ms 3804 KB Output is correct
22 Correct 76 ms 3384 KB Output is correct
23 Correct 73 ms 3380 KB Output is correct
24 Correct 73 ms 3388 KB Output is correct
25 Correct 74 ms 3384 KB Output is correct
26 Correct 82 ms 3796 KB Output is correct