結果

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

ソースコード

diff #

def bits(p, n):
    a = [0] * n
    for i in range(pow(p, n)):
        x = i
        for j in range(n):
            a[j] = x % p
            x //= p
        yield a

input()
a = list(map(int, input().split()))

ok = False
for es in bits(3, len(a)):
    b = [0, 0, 0]
    for i in range(len(a)):
        b[es[i]] += a[i]
    if b[0] == b[1] == b[2]:
        ok = True
        break

print('Yes' if ok else 'No')
0