Submission
Status:
[PPPPP][-SSSS]
Subtask/Task Score:
{50/50}{0/50}
Score: 50
User: Chawin
Problemset: จุดแวะพัก
Language: cpp
Time: 0.005 second
Submitted On: 2026-03-21 23:37:02
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int n, k;
cin >> n >> k;
cin.ignore();
vector<pair<int, string>> v;
while(n--){
string note;
getline(cin, note);
stringstream ss(note);
string name;
ss >> name;
int x, cnt = 0;;
while(ss >> x){
if(x < k) cnt++;
else if(x == k){
v.push_back({cnt, name});
break;
}
else break;
}
}
sort(v.begin(), v.end());
if(v.empty()) cout << -1;
else{
for(auto &x : v){
cout << x.second << " ";
}
}
return 0;
}