답안 #897700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897700 2024-01-03T15:04:17 Z LCJLY Sure Bet (CEOI17_sure) C++14
60 / 100
2000 ms 5104 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl; 
#define show4(x,y) for(auto it:x) cout << it << " "; cout << #y << endl;
typedef pair<int,int>pii;
typedef pair<pii,pii>pi2;

void solve(){	
	int n;
	cin >> n;
	ld arr[n];
	ld arr2[n];
	
	for(int x=0;x<n;x++){
		cin >> arr[x] >> arr2[x];
		if(arr[x]<1.0) arr[x]=1.0;
		if(arr2[x]<1.0) arr2[x]=1.0;
	}
	
	sort(arr,arr+n,greater<ld>());
	sort(arr2,arr2+n,greater<ld>());
	
	ld prefix[n];
	
	ld counter=0.0;
	for(int x=0;x<n;x++){
		counter+=arr2[x];
		prefix[x]=counter;
	}
	
	ld best=0.0;
	counter=0.0;
	for(int x=0;x<n;x++){
		int l=0;
		int r=n-1;
		int mid;
		int cur=0;
		counter+=arr[x];
		
		//show(counter,counter);
		
		while(l<=r){
			mid=(l+r);
			
			ld hold=counter; //winning for arr
			ld win=prefix[mid]; //winning for arr2
			
			
			if(hold>=win){
				cur=mid;
				l=mid+1;
			}
			else r=mid-1;
		}
		
		//show(cur,cur);
		best=max(best,min(counter-(ld)(cur+x+2),prefix[cur]-(ld)(cur+x+2)));
		if(cur<n-1) cur++;
		
		best=max(best,min(counter-(ld)(cur+x+2),prefix[cur]-(ld)(cur+x+2)));
		
		//show(best,best);
	}
	
	cout << fixed << setprecision(4) << best;
}
 
int32_t main(){										
	ios::sync_with_stdio(0);	
	cin.tie(0);
	//freopen("redistricting.in", "r", stdin);
	//freopen("redistricting.out", "w", stdout);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Execution timed out 2029 ms 5104 KB Time limit exceeded
18 Halted 0 ms 0 KB -