답안 #796704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796704 2023-07-28T15:53:02 Z acatmeowmeow Sure Bet (CEOI17_sure) C++11
0 / 100
1 ms 340 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>());
	for (int i = 1; i <= n; i++) prefix[i] = max(prefix[i - 1], se[i] - (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];
			int rem = min(n, (int)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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -