Submission
Status:
[P-SSS][-SSSS]
Subtask/Task Score:
{0/50}{0/50}
Score: 0
User: vachirasawin
Problemset: จุดแวะพัก
Language: cpp
Time: 0.009 second
Submitted On: 2026-03-13 00:27:05
// grader-chan
// c2_ds66_rest.cpp | c2_ds66_rest
#include <bits/stdc++.h>
using namespace std;
#include <set>
#include <functional>
int N, K;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> N >> K;
set<pair<int, string>, greater<pair<int, string>>> tourists;
for (int i = 0; i < N; i++) {
string name;
cin >> name;
int x, t = 0;
bool insertSet = false;
while (true) {
while (cin.peek() == ' ') cin.ignore();
if (cin.peek() == '\n' || cin.peek() == EOF) {
break;
}
if (cin >> x) {
if (x == K) insertSet = true;
else t++;
} else {
cin.clear();
break;
}
}
if (insertSet) tourists.insert({t, name});
}
for (auto it = tourists.rbegin(); it != tourists.rend(); it++) {
cout << it->second << " ";
}
return 0;
}