답안 #924686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924686 2024-02-09T12:51:04 Z NK_ Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 460 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 vl = V<ll>;

const ll MUL = ll(1e4);

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

	int N; cin >> N;

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

	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;

	ll ans = 0;
	for(int x = 2; x <= 2 * N; x++) {
		// cout << x << " ===> " << endl;
		// take x odds	
		auto F = [&](int i) {
			ll res = min(A[i - 1] - x * 1LL * MUL, B[x - 1 - i] - x * 1LL * MUL);
			// cout << i << " => " << A[i - 1] - x * MUL << " " << B[x - 1 - i] - x * MUL << " => " << res << endl;
			ans = max(ans, res); return res;
		};

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

		for(int y = 1; y < x; y++) F(y);

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

	ll ansr = ans % MUL, ansi = (ans - ansr) / MUL;

	db ANS = ansi + (ansr / db(MUL));

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

	exit(0-0);
}
# 결과 실행 시간 메모리 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 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 456 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 456 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 456 KB Output isn't correct
7 Halted 0 ms 0 KB -