Submission #584819

# Submission time Handle Problem Language Result Execution time Memory
584819 2022-06-28T04:16:01 Z amunduzbaev Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 212 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();
		res = max(res, a[i] - i - j - 2);
	}
	
	for(int i=0;i<n;i++){
		int j = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		res = max(res, b[i] - i - j - 2);
	}
	
	//~ 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";
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -