Submission #230491

# Submission time Handle Problem Language Result Execution time Memory
230491 2020-05-10T08:30:52 Z islingr Sure Bet (CEOI17_sure) C++14
100 / 100
158 ms 5240 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(x, v) for (auto &x : v)

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()

using ld = long double;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n; cin >> n;
	vector<ld> a(n + 1), b(n + 1);
	a[0] = b[0] = 1e6;
	rep(i, 0, n) cin >> a[i + 1] >> b[i + 1];
	sort(rall(a)); sort(rall(b));
	a[0] = b[0] = 0;
	rep(i, 0, n) a[i + 1] += a[i], b[i + 1] += b[i];
	auto f = [&](int x, int y) -> ld {
		return min(a[x], b[y]) - x - y;
	};
	ld ans = 0;
	rep(x, 0, n + 1) {
		int l = 0, r = n;
		while (r - l >= 5) {
			int mid = l + (r - l) / 2;
			if (f(x, mid) < f(x, mid + 1))
				l = mid;
			else r = mid + 1;
		}
		rep(i, l + 1, r + 1) if (f(x, l) < f(x, i)) l = i;
		ans = max(ans, f(x, l));
	}
	cout << fixed << setprecision(4) << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 143 ms 4856 KB Output is correct
18 Correct 150 ms 4924 KB Output is correct
19 Correct 148 ms 4856 KB Output is correct
20 Correct 147 ms 4820 KB Output is correct
21 Correct 158 ms 5196 KB Output is correct
22 Correct 147 ms 4856 KB Output is correct
23 Correct 146 ms 4856 KB Output is correct
24 Correct 146 ms 4856 KB Output is correct
25 Correct 148 ms 4984 KB Output is correct
26 Correct 157 ms 5240 KB Output is correct