Submission #796716

# Submission time Handle Problem Language Result Execution time Memory
796716 2023-07-28T16:06:38 Z acatmeowmeow Sure Bet (CEOI17_sure) C++11
60 / 100
2000 ms 4288 KB
#include <bits/stdc++.h>

using namespace std;

//#define int long long 

const int N = 1e5;
int n;
double f[N + 5], se[N + 5], prefix[N + 5];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> f[i] >> se[i];
	sort(f + 1, f + n + 1, greater<double>());
	sort(se + 1, se + n + 1, greater<double>());
	double seValue = se[1];
	for (int i = 1; i <= n; i++, seValue += se[i]) prefix[i] = max(prefix[i - 1], seValue - (double)i);
	double l = -1e18, r = 1e18, ans = -1e18;
	const double eps = 1e-9;
	while (r - l > eps) {
		double m = (l + r)/2.0, fValue = 0.0;
		bool valid = false;
		for (int i = 0; i <= n; i++) {
			fValue += f[i];
			long long rem = min((long long)n, (long long)floor(fValue - m) - i);
			if(rem < 0) continue;
			valid |= prefix[rem] - (double)i > m || abs(prefix[rem] - (double)i - m) < eps;
		}
		if (valid) ans = m, l = m;
		else r = m;
	}
	cout << fixed << setprecision(4) << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 91 ms 4008 KB Output is correct
18 Correct 88 ms 3920 KB Output is correct
19 Correct 88 ms 3916 KB Output is correct
20 Correct 88 ms 4008 KB Output is correct
21 Execution timed out 2074 ms 4288 KB Time limit exceeded
22 Halted 0 ms 0 KB -