Submission
Status:
[PTSSS][PPPTS]
Subtask/Task Score:
{0/50}{0/50}
Score: 0
User: Seng
Problemset: จุดแวะพัก
Language: cpp
Time: 1.095 second
Submitted On: 2026-05-31 22:14:00
#include <bits/stdc++.h>
using namespace std;
using pis = pair<int, string>;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n, k;cin >> n >> k;
string str;cin >> str;
string str2 = str;
priority_queue<pis, vector<pis>, greater<pis>> pq;
while(n--){
str = str2;
int x = 0, cnt = 0;
bool chk = false;
if(n > 0){
cin >> str2;
while('9' - str2[0] >= 0){
if(!chk) x = stoi(str2);
if(x < k) cnt++;
else if(x == k) pq.push({cnt, str});
if(x >= k) chk = true;x++;
cin >> str2;
}
}
else{
cin >> x;
while(x < k){
cnt++;
cin >> x;
}
if(x == k) pq.push({cnt, str});
}
}
int ss = min(3, (int)pq.size());
for(int i = 0; i < ss; i++){
cout << pq.top().second << " ";
pq.pop();
}
if(ss == 0) cout << -1;
}