結果

問題 No.349 干支の置き物
ユーザー gorugo30gorugo30
提出日時 2021-02-23 21:03:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 82,112 KB
実行使用メモリ 54,072 KB
最終ジャッジ日時 2024-09-22 15:20:50
合計ジャッジ時間 2,383 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
cnt = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
eto = ["ne", "ushi", "tora", "u", "tatsu", "mi", "uma", "hitsuji", "saru", "tori", "inu", "i"]
for i in range(N):
    cnt[eto.index(input())] += 1

before = -1
for i in range(N):
    maxcnt = 0
    oku = -1
    for j in range(12):
        if cnt[j] > maxcnt and before != j:
            maxcnt = cnt[j]
            oku = j
    if oku == -1 and max(cnt) != 0:
        print("NO")
        exit()
    before = oku
    cnt[oku] -= 1
print("YES")
0