結果

問題 No.1594 Three Classes
コンテスト
ユーザー RyoSci
提出日時 2021-07-09 21:45:40
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 509 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 696 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 30,832 KB
最終ジャッジ日時 2026-03-22 18:04:49
合計ジャッジ時間 27,836 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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