結果

問題 No.1594 Three Classes
ユーザー RyoSciRyoSci
提出日時 2021-07-09 22:58:09
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 361 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 857 ms
使用メモリ 81,800 KB
最終ジャッジ日時 2022-12-17 02:07:53
合計ジャッジ時間 6,521 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 354 ms
81,800 KB
testcase_01 AC 76 ms
75,372 KB
testcase_02 AC 77 ms
75,500 KB
testcase_03 AC 103 ms
81,344 KB
testcase_04 AC 348 ms
81,000 KB
testcase_05 AC 350 ms
81,508 KB
testcase_06 AC 87 ms
80,656 KB
testcase_07 AC 95 ms
81,328 KB
testcase_08 AC 361 ms
81,384 KB
testcase_09 AC 350 ms
81,380 KB
testcase_10 AC 348 ms
81,304 KB
testcase_11 AC 359 ms
81,600 KB
testcase_12 AC 357 ms
81,564 KB
testcase_13 AC 75 ms
75,796 KB
testcase_14 AC 138 ms
81,328 KB
testcase_15 AC 120 ms
81,132 KB
testcase_16 AC 108 ms
81,480 KB
testcase_17 AC 101 ms
81,172 KB
testcase_18 AC 75 ms
75,676 KB
testcase_19 AC 94 ms
81,124 KB
testcase_20 AC 91 ms
81,164 KB
権限があれば一括ダウンロードができます

ソースコード

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