백준 13414 수강신청

supway·2022년 2월 22일
0

백준

목록 보기
28/62

백준 13414

#include <bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
int k, l;
unordered_map<string,int> s;
vector<pair<int, string>>v;
int main() {
	ios::sync_with_stdio(0); cin.tie(0);

	cin >> k >> l;

	for(int i=0;i<l;i++){

		string s1;

		cin >> s1;

		s[s1] = i; 
	}


	for (auto c : s) {
		v.push_back({ c.second, c.first });
	}
	sort(v.begin(), v.end());

	int cnt = 0;
	for (auto c : v) {
		if (cnt == k) break;
		cout << c.second << '\n';
		cnt++;
	}
}
profile
개발잘하고싶은사람

0개의 댓글