よじろめ覚書

私の理解度重視のソースコードです。

ABC091B - Two Colors Card Game

問題:B - Two Colors Card Game

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    int n, m, ans = 0, score = 0;
    string s[100], t[100];

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> s[i];
    }
    cin >> m;
    REP(i, m) {
        cin >> t[i];
    }
    REP(i, n) {
        score = 0;
        REP(j, n) {
            if (s[i] == s[j]) {
                score++;
            }
        }
        REP(j, m) {
            if (s[i] == t[j]) {
                score--;
            }
        }
        
        ans = max(ans, score);
    }
    
    cout << ans << "\n";
    return 0;
}