結果

問題 No.1594 Three Classes
ユーザー RyoSciRyoSci
提出日時 2021-07-09 22:58:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 77,268 KB
最終ジャッジ日時 2023-08-10 06:55:20
合計ジャッジ時間 5,333 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 298 ms
77,200 KB
testcase_01 AC 66 ms
71,564 KB
testcase_02 AC 67 ms
71,232 KB
testcase_03 AC 89 ms
77,252 KB
testcase_04 AC 312 ms
77,168 KB
testcase_05 AC 310 ms
77,132 KB
testcase_06 AC 78 ms
76,516 KB
testcase_07 AC 86 ms
77,208 KB
testcase_08 AC 324 ms
77,172 KB
testcase_09 AC 315 ms
77,084 KB
testcase_10 AC 298 ms
77,208 KB
testcase_11 AC 311 ms
77,172 KB
testcase_12 AC 305 ms
77,196 KB
testcase_13 AC 68 ms
71,084 KB
testcase_14 AC 122 ms
77,268 KB
testcase_15 AC 115 ms
76,976 KB
testcase_16 AC 100 ms
77,156 KB
testcase_17 AC 93 ms
77,084 KB
testcase_18 AC 71 ms
71,232 KB
testcase_19 AC 84 ms
76,840 KB
testcase_20 AC 81 ms
76,540 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