Submission #498386

# Submission time Handle Problem Language Result Execution time Memory
498386 2021-12-25T06:00:04 Z Ierus Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
typedef long long ll;
const int E = 1e6+777;
const long long inf = 1e18+777;
const int N = 1e5+777;
const int MOD = 1e9+7;
const bool I = 1;
int n, color[N], v1[N], sum1;
double a[N], b[N], pref[3][N];
double F(int x, int y){
	return (double)min(pref[1][x] - (x + y), pref[2][y] - (x + y));
}
double get(double res = 0.0){
	for(int i = 1; i <= n; ++i){
		int L = 2, R = n, o = 1;
		while(L <= R){
			int M = (L + R) >> 1;
			if(F(i, M-1) <= F(i, M+1)){
				L = (o = M) + 1;
			}else R = M - 1;
		}
		res = max(res, F(i, o));
	}
	for(int i = 1; i <= n; ++i){
		int L = 2, R = n, o = 1;
		while(L <= R){
			int M = (L + R) >> 1;
			if(F(M-1, o) <= F(M, 0)){
				L = (o = M) + 1;
			}else R = M - 1;
		}
		res = max(res, F(o, i));
	}
	return res;
}
int main(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> a[i] >> b[i];
	}
	sort(a+1,a+1+n), reverse(a+1,a+1+n);
	sort(b+1,b+1+n), reverse(b+1,b+1+n);
	for(int i = 1; i <= n; ++i){
		pref[1][i] = pref[1][i-1] + a[i];
		pref[2][i] = pref[2][i-1] + b[i];
	}
	cout << fixed << setprecision(4) << get() << '\n';
};











# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct