Submission
Status:
[PTSSS][PPPTS]
Subtask/Task Score:
{0/50}{0/50}
Score: 0
User: Seng
Problemset: จุดแวะพัก
Language: cpp
Time: 1.092 second
Submitted On: 2026-06-02 19:34:38
#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;
int cnt_str = 0;
string str;cin >> str;
cnt_str++;
string str2 = str;
priority_queue<pis, vector<pis>, greater<pis>> pq;
str = str2;
int x = 0, cnt = 0;
//bool chk = false;
cin >> x;//number
while(cnt_str < n){
//if(!chk)
if(x < k) cnt++;
else if(x == k) pq.push({cnt, str});
//if(x >= k) chk = true;x++;
cin >> str2;
if('9' - str2[0] < 0){
cnt_str++;
str = str2;
x = 0;
cnt = 0;
cin >> x;
}
else x = stoi(str2);
}
//x = stoi(str2);
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;
}