Submission #938303

# Submission time Handle Problem Language Result Execution time Memory
938303 2024-03-05T04:27:08 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 348 KB
///*                                                    __                    __                        __                    */
///*        ======     _      /| /|  __   _            /   |  |   /|  |   @  |    |  |  | /   /| |\  | /   |  |  @ | /        */
///* \-       ||  |_| |_     / |/ | |  | |_  |-        |   |--|  /-|  |   |  \ \  |==|  |-   /=| | \ | |   |--|  | |-         */
///*          ||  | | |_    /     | |__|  _| |_        \__ |  | /  |  |__ |  __|  |  |  | \ /  | |  \| \__ |  |  | | \        */
///* 
 
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define int long long
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef vector<pii> vii;
const int N = 3e5+50, inf = 1e18, mod = 1e9+7;

void solve(){
	int n;
	cin >> n;
	vd a(n+2, 0), b(n+2, 0);
	for(int i = 0; i < n; i++)cin >> a[i] >> b[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	double ans = 0;
	vd pr;pr.pb(0);
	for(auto i:b)pr.pb(pr.back()+i);
	double sma = 0;int cnt = 0;
	for(int i = 0; i < n; i++){
		sma+=a[i];
		cnt++;
		
		auto f = [&](int ps){
			return pr[ps] - ps;
		};
		int l = 0, r = n, re = 30;
		while(--re > 0){
			int m1 = l+(l+r)/3;
			int m2 = r-(l+r)/3;
			if(f(m1) >= f(m2)){
				r = m2;
			}else l = m1;
			ans = max(ans, min(sma - (cnt+m1), pr[m1] - (cnt+m1)));
			ans = max(ans, min(sma - (cnt+m2), pr[m2] - (cnt+m2)));
			//cout << m1 << '\n';
		}
		//cout << '\n';
	}
	cout << fixed << setprecision(4);
	cout << ans << '\n';
}
main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int test = 1;
	//cin >> test;
	while(test--){
		solve();
	}
}
 
 
 
 
 
 
 
 
 
 
 
 
 

Compilation message

sure.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main(){
      | ^~~~
# Verdict Execution time Memory 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 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -