結果

問題 No.1594 Three Classes
ユーザー 大橋佐和
提出日時 2022-05-06 21:22:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 584 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-11-16 08:39:43
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

answer = False
for in_A in range(1 << n):
    p_A = 0
    for j in range(n):
        if in_A >> j & 1:
            p_A += e[j]
    ex_A = (1 << n) - in_A - 1
    in_B = ex_A
    while in_B > 0:
        p_B = 0
        for j in range(n):
            if in_B >> j & 1:
                p_B += e[j]
        p_C = total_e - p_A - p_B
        if p_A == p_B and p_B == p_C:
            answer = True
            break
        in_B -= 1
        in_B &= ex_A
    if answer:
        break

print("Yes" if answer else "No")
0