Submission

Status:

[PPPPP][PPPPP]

Subtask/Task Score:

{50/50}{50/50}

Score: 100

User: Test

Problemset: จุดแวะพัก

Language: cpp

Time: 0.007 second

Submitted On: 2026-03-06 14:41:45

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    cin.ignore(); // del newline
    vector<pair<bool,pair<int,string>>> v;
    for(int i=0;i<n;i++){
        bool ck = 1;
        string line;
        getline(cin,line); //?Ѻ??????
        stringstream ss(line); //?¡??
        int cnt = 0;
        int y;
        string name;
        ss >> name; //???á??ͪ???
        while(ss >> y){ //????͹pointer?????
            if(y<k){
                cnt+=1;
            }
            if(y==k){
                ck=0;
            }
        }
        v.push_back({ck,{cnt,name}});
    }
    sort(v.begin(),v.end());
    int ct=0;
    for(int i=0;i<n;i++){
        if(v[i].first==0 && ct<3){
            cout << v[i].second.second <<  " ";
            ct++;
        }
    }
    if(ct==0) cout << -1;
}