Submission

Status:

[PPPPP][PP-SS]

Subtask/Task Score:

{50/50}{0/50}

Score: 50

User: tha_smith

Problemset: จุดแวะพัก

Language: cpp

Time: 0.007 second

Submitted On: 2026-03-07 20:50:53

#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>> v; string name,s;
	cin >> N >> K;
	for(int i=0; i<N; i++) {
		cin >> name;
		getline(cin,s);
		string num=""; bool rest=0,n=0; int count=0;
		for(int j=0; j<s.size(); j++) {
			if(s[j]!=' ') {
				num+=s[j];
				n=1;
			}
			if((s[j]==' '&&n==1)||(j==s.size()-1&&n==1)) {
				int NUM = stoi(num);
				if(NUM==K) {
					rest=1;
					break;
				}
				else {
					count++;
					num="";
					n=0;
				}
			}
		}
		if(rest)
			v.push_back({count,name});
	}
	if(v.empty()) {
		cout << -1;
	}
	else {
		sort(v.begin(),v.end());
		for(int i=0; i<3; i++) {
			cout << v[i].second << ' ';
		}
	}
}