Submission
Status:
[PP-SS][-SSSS]
Subtask/Task Score:
{0/50}{0/50}
Score: 0
User: tha_smith
Problemset: จุดแวะพัก
Language: cpp
Time: 0.007 second
Submitted On: 2026-03-03 15:54:59
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0),cin.tie(0);
int N,K; vector<pair<int,string>> m;
cin >> N >> K;
for(int i=0; i<N; i++) {
string s, name, num=""; bool nus=0,rest=0; int count=0;
cin >> name;
getline(cin,s);
for(int j=0; j<s.size(); j++) {
if(s[j]>='0' && s[j]<='9') {
num+=s[j];
nus=1;
}
if((nus && s[j]==' ') || (nus && (j==s.size()-1))) {
int NUM = stoi(num);
//cout << name << ' ' << NUM << '\n';
if(s[j]==' ' && nus && NUM!=K) {
count++;
num="";
nus=0;
}
else if(NUM==K) {
rest=1;
num="";
}
}
}
if(rest)
m.push_back({count,name});
//cout << count << ' ' << name << ' ' << rest << '\n';
}
if(m.empty()) {
cout << -1;
return 0;
}
sort(m.begin(),m.end());
for(int i=0; i<m.size()&&i<3; i++) {
cout << m[i].second << ' ';
}
}