-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProblem_#99_Largest_exponential.cpp
63 lines (55 loc) · 1.05 KB
/
Problem_#99_Largest_exponential.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<double, double> dd;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
vii v;
const double EPS = 1e-6;
int cmp(ii a, ii b){ //is left < right ?
double c = a.first; // base
double d = b.first; // base
return a.second*log(c) <= b.second*log(d) + EPS;
}
void quickSort(int from, int to){
if(from >= to){
return;
}
ii p = v[to];
int mid = from;
for(int i=from;i<to;i++){
if(cmp(v[i], p)){
swap(v[i], v[mid]);
mid++;
}
}
swap(v[to], v[mid]);
quickSort(from, mid-1);
quickSort(mid+1, to);
}
int main(){
int n; cin >> n;
v = vii(n);
for(int i=0;i<n;i++){
int b, e; cin >> b >> e;
v[i] = ii(b, e);
}
quickSort(0, n-1);
int k; cin >> k;
k--;
cout << v[k].first <<" "<<v[k].second << endl;
}