はまやんはまやんはまやん

hamayanhamayan's blog

多数決 [パ研合宿2019 第3日「パ研杯2019」 B]

https://atcoder.jp/contests/pakencamp-2019-day3/tasks/pakencamp_2019_day3_b

解説

https://atcoder.jp/contests/pakencamp-2019-day3/submissions/9144087

白の人数と黒の人数を数えて多い方が答えになる。
C++なら==で比較すれば判定できる。

int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;

    int black = 0, white = 0;

    rep(i, 0, N) {
        string s; cin >> s;
        if (s == "black") black++;
        else white++;
    }

    if (black < white) cout << "white" << endl;
    else cout << "black" << endl;
}