답안 #865419

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865419 2023-10-24T08:07:03 Z vjudge1 Sure Bet (CEOI17_sure) C++
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#include <sstream>
#include <fstream>
#define et "\n"
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ioi ios::sync_with_stdio(false); cin.tie(0);  cout.tie(0)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define M 1000000007
 
using namespace std;
ll n,m,k;

string s1;
map <ll,ll> mp;
double ans,cnt,cnt1;
double a[211111],b[211111];
void solve() {
	cin >> n;
	ans = 0;
	for (int i = 1;i <= n;i++) {
		cin >> a[i] >> b[i];
	}
	sort(a + 1,a + n + 1);
	sort(b + 1,b + n + 1);
	cnt = 0;
	cnt1 = 0;
	ll k = n;
	for (int i = n;i >= 1;i --) {
		cnt += a[i] - 1.0;
		cnt1 -= (double)(n - i) + 1.0;
		for (int j = n;j >= 1;j--) {
			cnt1 += b[j] - 1.0;
			cnt -= 1.0;
			if (ans > min(cnt,cnt1)) {
				cnt ++;
				cnt1 -= b[j];
				cnt1 ++;
				k = j;
				break;
			}
			ans = max(ans,min(cnt,cnt1));
		}
		cnt += (double)(n - k);
		cnt1 = 0;
//		cout << ans << ' ' << i << ' ' << a[i] << ' ' << cnt << ' ' << cnt1 << ' ' << k << et;
	}
	printf("%.4lf",(double)ans);
}
int main() {
	ioi;
	ll tt = 1;
//	cin >> tt;
	while (tt--) {
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2392 KB Output isn't correct
4 Halted 0 ms 0 KB -