Submission #163347

# Submission time Handle Problem Language Result Execution time Memory
163347 2019-11-12T18:13:25 Z Knps4422 Sure Bet (CEOI17_sure) C++14
100 / 100
250 ms 5240 KB
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const int mod=1e9+7;
using namespace std;

int n;
double a[100005], b[100005];
double sum_a[100005], sum_b[100005];
int main(){	
	cin >> n;
	for(int i = 1; i <= n ; i++){
		cin >> a[i] >> b[i];
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	reverse(a+1,a+n+1);
	reverse(b+1,b+n+1);
	for(int i = 1; i <= n; i++){
		sum_a[i] = sum_a[i-1] + a[i];
		sum_b[i] = sum_b[i-1] + b[i];
	}
	double answer = 0;
	for(int i = 1; i <= n ; i++){
		int l = 1, r = n;
		while(l < r){
			int mid = (l+r)/2;
			if(sum_b[mid] >= sum_a[i]){
				r = mid;
			}else{
				l = mid + 1;
			}
		} 
		//cout << i << ' ' << l << '\n';
		answer = max(answer,
			min(sum_a[i]-i-l,sum_b[l]-i-l));
		answer = max(answer,
			min(sum_a[i]-i-l+1,sum_b[l-1]-i-l+1));

	}
	printf("%.4lf",(double)answer);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 380 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 380 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 248 KB Output is correct
17 Correct 206 ms 4904 KB Output is correct
18 Correct 206 ms 4948 KB Output is correct
19 Correct 203 ms 4856 KB Output is correct
20 Correct 202 ms 5000 KB Output is correct
21 Correct 250 ms 5240 KB Output is correct
22 Correct 201 ms 4984 KB Output is correct
23 Correct 200 ms 4976 KB Output is correct
24 Correct 202 ms 4856 KB Output is correct
25 Correct 200 ms 4856 KB Output is correct
26 Correct 231 ms 5240 KB Output is correct