Submission #642658

# Submission time Handle Problem Language Result Execution time Memory
642658 2022-09-20T10:24:30 Z ymm Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 100'010;
double a[N], b[N];
int n;

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	cin >> n;
	Loop (i,1,n+1) {
		cin >> a[i] >> b[i];
		--a[i]; --b[i];
	}
	sort(a+1, a+n+1); reverse(a+1, a+n+1);
	sort(b+1, b+n+1); reverse(b+1, b+n+1);
	Loop (i,0,n) {
		a[i+1] += a[i];
		b[i+1] += b[i];
	}
	double ans = 0;
	for (int i=0,j=0; i < n; ++i) {
		while (j<n && a[i]-j-1 >= b[j+1]-i)
			++j;
		ans = max(ans, min(a[i]-j, b[j]-i));
	}
	for (int i=0,j=0; i < n; ++i) {
		while (j<n && b[i]-j-1 >= a[j+1]-i)
			++j;
		ans = max(ans, min(b[i]-j, a[j]-i));
	}
	cout << fixed << setprecision(4) << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -