-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathq1.cpp
More file actions
48 lines (40 loc) · 754 Bytes
/
Copy pathq1.cpp
File metadata and controls
48 lines (40 loc) · 754 Bytes
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
#include <iostream>
#include <algorithm>
#include <functional>
using std::endl;
using std::cout;
using std::cin;
using std::sort;
using std::max_element;
using std::greater;
// 1. 牛的选举
struct a {
int value = 0;
int index = 0;
bool operator < (const a &l) const {
return value > l.value;
}
}a[60000];
int b[60000];
int main(int argc, char *argv[]) {
int n = 0;
int k = 0;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i].value >> b[i];
}
for (int i = 0; i < n; i++) {
a[i].index = i;
}
sort(a, a + n);
int maxValue = 0;
int maxIndex = 0;
for (int i = 0; i < k; i++) {
if (b[a[i].index] > maxValue) {
maxValue = b[a[i].index];
maxIndex = a[i].index;
}
}
cout << maxIndex + 1 << endl;
return 0;
}