https://www.acmicpc.net/problem/7785
#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;
int main()
{
int N;
cin >> N;
string name, status;
unordered_map<string, string> logs;
for (int i = 0; i < N; ++i)
{
cin >> name >> status;
if (status == "leave")
logs.erase(name);
else logs.insert({ name, status });
}
vector<string> names;
for (const auto& log : logs)
names.push_back(log.first);
sort(names.begin(), names.end(), greater<>());
for (const string& name : names)
cout << name << "\n";
return 0;
}
'코딩테스트' 카테고리의 다른 글
[프로그래머스] 주식가격(C++) (0) | 2025.05.22 |
---|---|
[백준] 온라인 저지 13414번 : 수강신청(C++), 해시맵 (0) | 2025.04.28 |
[백준] 온라인 저지 18870번 : 좌표 압축(C++), 이분탐색 (0) | 2025.04.18 |
[백준] 온라인 저지 2667번 : 단지번호 붙이기(C++), DFS (0) | 2025.04.15 |
[백준] 온라인 저지 7576번 : 토마토(C++), BFS (0) | 2025.04.14 |