반응형

 

 

<코드>

#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;

int N;
string s1, s2;
set<string, greater<string>> s;
map<string, bool> m;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;
    

    for (int i = 0; i < N; i++)
    {
        cin >> s1 >> s2;
        
        if (s2 == "enter") m[s1] = true;
        else m[s1] = false;

        s.insert(s1);
    }

    for (auto it = s.begin(); it != s.end(); it++)
    {
        string member = *it;
        if (m[member]) cout << member << '\n';
    }
    
}

 

 

 

www.acmicpc.net/problem/7785

 

7785번: 회사에 있는 사람

첫째 줄에 로그에 기록된 출입 기록의 수 n이 주어진다. (2 ≤ n ≤ 106) 다음 n개의 줄에는 출입 기록이 순서대로 주어지며, 각 사람의 이름이 주어지고 "enter"나 "leave"가 주어진다. "enter"인 경우는

www.acmicpc.net

 

반응형

'🧩PS > 🥈Nomal' 카테고리의 다른 글

[C/C++] 백준 5525번 - IOIOI  (0) 2021.04.06
[C/C++] 백준 4358번 - 생태학  (0) 2021.04.06
[C/C++] 백준 5052번 - 전화번호 목록  (0) 2021.04.06
[C/C++] 백준 1120번 - 문자열  (0) 2021.04.05
[C/C++] 백준 11655번 - ROT13  (0) 2021.04.05

+ Recent posts