結果

問題 No.1594 Three Classes
ユーザー RyoSciRyoSci
提出日時 2021-07-09 22:58:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-04-28 00:32:38
合計ジャッジ時間 3,623 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 243 ms
75,776 KB
testcase_01 AC 34 ms
52,352 KB
testcase_02 AC 31 ms
51,968 KB
testcase_03 AC 58 ms
76,252 KB
testcase_04 AC 244 ms
75,776 KB
testcase_05 AC 240 ms
75,992 KB
testcase_06 AC 45 ms
61,056 KB
testcase_07 AC 56 ms
76,028 KB
testcase_08 AC 246 ms
75,904 KB
testcase_09 AC 241 ms
75,776 KB
testcase_10 AC 238 ms
76,416 KB
testcase_11 AC 244 ms
76,064 KB
testcase_12 AC 246 ms
76,416 KB
testcase_13 AC 35 ms
52,096 KB
testcase_14 AC 76 ms
75,776 KB
testcase_15 AC 74 ms
75,776 KB
testcase_16 AC 61 ms
76,032 KB
testcase_17 AC 59 ms
76,092 KB
testcase_18 AC 35 ms
51,584 KB
testcase_19 AC 52 ms
66,816 KB
testcase_20 AC 49 ms
67,328 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