답안 #584820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584820 2022-06-28T04:17:09 Z amunduzbaev Sure Bet (CEOI17_sure) C++17
100 / 100
86 ms 4412 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
typedef int64_t ll;

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	vector<double> a(n), b(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	a.insert(a.begin(), 0);
	b.insert(b.begin(), 0);
	for(int i=1;i<=n;i++){
		a[i] += a[i-1];
	}
	for(int i=1;i<=n;i++){
		b[i] += b[i-1];
	}
	
	//~ for(int i=1;i<=n;i++){
		//~ cout<<a[i]<<" ";
	//~ } cout<<"\n";
	//~ for(int i=1;i<=n;i++){
		//~ cout<<b[i]<<" ";
	//~ } cout<<"\n";
	
	double res = -1e9;
	for(int i=0;i<=n;i++){
		int j = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		if(j <= n && a[i] <= b[j]){
			res = max(res, a[i] - i - j);
		}
	}
	
	for(int i=0;i<=n;i++){
		int j = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		if(j <= n && b[i] <= a[j]){
			res = max(res, b[i] - i - j);
		}
	}
	
	//~ for(int i=0;i<=n;i++){
		//~ for(int j=0;j<=n;j++){
			//~ res = max(res, min(a[i], b[j]) - i - j);
		//~ }
	//~ }
	
	//~ printf("%.4lf",(double)res);
	cout<<fixed<<setprecision(4)<<res<<"\n";
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 83 ms 2648 KB Output is correct
18 Correct 81 ms 3928 KB Output is correct
19 Correct 79 ms 4028 KB Output is correct
20 Correct 78 ms 4036 KB Output is correct
21 Correct 85 ms 4300 KB Output is correct
22 Correct 80 ms 4016 KB Output is correct
23 Correct 82 ms 4024 KB Output is correct
24 Correct 83 ms 4032 KB Output is correct
25 Correct 80 ms 4016 KB Output is correct
26 Correct 86 ms 4412 KB Output is correct