Submission #2384263


Source Code Expand

#include<bits/stdc++.h>

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi v(n);
	rep(i , n){
		cin >> v[i];
	}
	
	SORT(v);
	
	int l = 0 , r = n - 2;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(2 * v[mid] <= v[n - 1]){
			l = mid;
		}else{
			r = mid;
		}
	}

	if(r != n - 1){
		if(abs(2 * v[r] - v[n - 1]) < abs(2 * v[l] - v[n - 1])){
			l = r;
		}
	}
	
	cout << v[n - 1] << " " << v[l] << endl;

	return 0;
}

Submission Info

Submission Time
Task D - Binomial Coefficients
User ezewin
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1239 Byte
Status AC
Exec Time 17 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample1.txt, sample2.txt
All even0.txt, even1.txt, float.txt, odd0.txt, odd1.txt, rnd_0.txt, rnd_1.txt, rnd_2.txt, rnd_3.txt, rnd_4.txt, rnd_5.txt, rnd_6.txt, rnd_7.txt, rnd_8.txt, rnd_9.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
even0.txt AC 17 ms 640 KB
even1.txt AC 17 ms 640 KB
float.txt AC 17 ms 640 KB
odd0.txt AC 17 ms 640 KB
odd1.txt AC 17 ms 640 KB
rnd_0.txt AC 16 ms 640 KB
rnd_1.txt AC 14 ms 640 KB
rnd_2.txt AC 15 ms 640 KB
rnd_3.txt AC 14 ms 640 KB
rnd_4.txt AC 12 ms 512 KB
rnd_5.txt AC 17 ms 640 KB
rnd_6.txt AC 14 ms 512 KB
rnd_7.txt AC 13 ms 512 KB
rnd_8.txt AC 15 ms 640 KB
rnd_9.txt AC 15 ms 640 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB