알고리즘/백준

백준 10527 Judging Troubles

등반 2021. 12. 27. 00:53

https://www.acmicpc.net/problem/10527

 

10527번: Judging Troubles

The NWERC organisers have decided that they want to improve the automatic grading of the submissions for the contest, so they now use two systems: DOMjudge and Kattis. Each submission is judged by both systems and the grading results are compared to make s

www.acmicpc.net

문제 해설

DOM과 Kattis에서 각각 채점한 기록이 주어지는데, 각각의 기록의 순서가 뒤죽박죽이 되었다.

이 경우, 채점 결과가 같을 수 있는 가장 큰 수를 구하는 문제다.

 

뒤죽박죽이 된 두 기록에서 같은 값의 짝을 맞추면 된다.

채점 결과의 횟수를 각각 구한 상태에서 더 적은 횟수를 가진 단체에 속한 기록은 모두 짝이 지어질 수 있다.

 

#include <iostream>
#define fio cin.tie(0)->sync_with_stdio(0)
using namespace std;

#include <map>
int main(){
    fio;
    int N; cin >> N;
    map<string, int> DOM, KAT;
    for(int i=0; i <N; i++){
        string S; cin >> S;
        DOM[S]++;
    }
    for(int i=0; i<N; i++){
        string S; cin >> S;
        KAT[S]++;
    }

    int ans = 0;
    map<string, int>::iterator iter;
    for(iter = DOM.begin(); iter != DOM.end(); iter++){
        if(KAT.find((*iter).first) != KAT.end()){
            ans += min((*iter).second, KAT[(*iter).first]);
        }
    }
    cout << ans;
    return 0;
}

'알고리즘 > 백준' 카테고리의 다른 글

백준 11116 교통량  (0) 2021.12.27
백준 10689 Hamza  (0) 2021.12.27
백준 9733 꿀벌  (0) 2021.12.27
백준 8641 Sklep  (0) 2021.12.27
백준 6973 Dynamic Dictionary Coding  (0) 2021.12.27