-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.cpp
More file actions
95 lines (79 loc) · 1.64 KB
/
Copy path5.cpp
File metadata and controls
95 lines (79 loc) · 1.64 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <bits/stdc++.h>
#define pbk push_back
#define p_q priority_queue
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
int N, K;
struct Song {
string title;
char genre;
int B;
double S;
int D;
Song(string& str, char _genre, int _B, double _S, int _D) {
title = str;
genre = _genre;
B = _B;
S = _S;
D = _D;
}
};
struct cmp {
bool operator() (const Song& a, const Song& b) {
if(a.B != b.B) return a.B < b.B;
if(a.D != b.D) return a.D < b.D;
return a.S > b.S;
}
};
p_q<Song, vector<Song>, cmp> pq;
void Input() {
cin >> N >> K;
while(N--) {
string str;
char genre;
int B, D;
double S;
cin >> str >> genre >> B >> S >> D;
pq.push(Song(str, genre, B, S, D));
}
}
string ans;
void Process() {
queue<Song> q;
int idx=1;
if(K==idx) {
ans = pq.top().title;
return;
}
Song before = pq.top();
pq.pop();
while(!pq.empty()) {
auto now = pq.top();
pq.pop();
if(before.genre == now.genre) {
q.push(now);
continue;
}
else {
idx++;
if(K==idx) {
ans = now.title;
return;
}
before = now;
while(!q.empty()) {
pq.push(q.front());
q.pop();
}
}
}
}
void Output() {
cout << ans;
}
int main() {
Input();
Process();
Output();
}