結果

問題 No.1594 Three Classes
ユーザー RyoSci
提出日時 2021-07-09 22:58:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2024-11-16 08:21:13
合計ジャッジ時間 4,227 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
e = list(map(int, input().split()))


def cal(x):
    tmp = []
    while x > 0:
        tmp.append(x % 3)
        x //= 3
    return [0]*(n-len(tmp))+tmp[::-1]


ans = "No"
for i in range(3**n):
    tmp = cal(i)
    cnt = [0]*3
    for j in range(n):
        if tmp[j] == 0:
            cnt[0] += e[j]
        elif tmp[j] == 1:
            cnt[1] += e[j]
        else:
            cnt[2] += e[j]
    if cnt[0] == cnt[1] and cnt[1] == cnt[2]:
        ans = "Yes"
        break

print(ans)
0