Submission
Status:
[PPPPP][PPPPP]
Subtask/Task Score:
{50/50}{50/50}
Score: 100
User: navysrimuang
Problemset: จุดแวะพัก
Language: cpp
Time: 0.008 second
Submitted On: 2026-03-18 15:12:33
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n,k;
cin >> n >> k;
cin.ignore();
vector<pair<int,string>> names(n),ok;
for(int i = 0;i<n;i++){
string full;
getline(cin,full);
stringstream ss(full);
string name;
ss >> name;
names[i].second = name;
names[i].first = -1;
int x;
int j = 0;
while(ss >> x){
if(x == k) names[i].first = j;
j++;
}
if(names[i].first != -1){
ok.push_back(names[i]);
}
}
sort(ok.begin(),ok.end());
if(ok.empty()) cout << -1 << "\n";
for(int i = 0;i<min(3,(int)ok.size());i++) cout << ok[i].second << " ";
return 0;
}