結果

問題 No.1594 Three Classes
ユーザー RyoSci
提出日時 2021-07-09 21:45:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 509 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,512 KB
最終ジャッジ日時 2024-07-01 15:45:36
合計ジャッジ時間 6,474 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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


def cal(x):
    tmp = ""
    while x > 0:
        tmp += str(x % 3)
        x //= 3
    return (n-len(tmp))*"0"+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