답안 #498433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498433 2021-12-25T07:59:45 Z syrtin Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair < int, int > pii;
typedef vector<int> vi;
typedef vector<long long> vll;
const int N = 2e5 + 123;
const ll mod = 1e9 + 7;
void solve(){
	int n, cnt = 0;
	cin >> n;
	double a[n], b[n], out = 0, s = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n), sort(b, b + n);
	for(int i = n - 2; i >= 0; i--) b[i] += b[i - 1];
	for(int i = n - 1; i >= 0; i--) {
		s += a[i] - 1;
		int p = s;
		cnt++;
		int l = max(n - 1 - p, -1), r = n;
		while(l + 1 < r) {
			int mi = l + (r - l) / 2;
			if(b[mi] - cnt <= s)r = mi;
			else l = mi;
		}
		if(r != n)out = max(out, b[r] - cnt - (n - r));
		if(r)out = max(out, s - (n - r) - 1);
	}
	cout << fixed << setprecision(9) << out;
}
int main() {
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int times = 1;
	//cin >> times;
    while(times--)solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -