-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRank_list.cpp
More file actions
52 lines (50 loc) · 1.17 KB
/
Rank_list.cpp
File metadata and controls
52 lines (50 loc) · 1.17 KB
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
#include <iostream>
#include <map>
#include <string>
#include <iterator>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
bool ord(pair<int,int> a, pair<int,int>b){
if(a.first == b.first){
if(a.second == b.second){
return a.first > b.first;
}
else{
return a.second < b.second;
}
}
else{
return a.first > b.first;
}
}
int main() {
unsigned int n;
unsigned int k;
cin >> n >> k;
vector<pair<int, int> > v;
for(int i = 0; i < n; i++){
int problems;
int time;
pair<int,int> paresin;
cin >> problems >> time;
paresin = make_pair(problems, time);
v.push_back(paresin);
}
sort(v.begin(),v.end(),ord);
int contador = 1;
for(int i = 0; i < n; i++){
int kreal = k-1;
if(v[i].first != v[kreal].first && v[i].second != v[kreal].second){
i = i+1;
}
if(i == kreal){
i = i+1;
}
if(v[i].first == v[kreal].first && v[i].second == v[kreal].second){
contador = contador +1;
}
}
cout << contador << endl;
}