結果

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

ソースコード

diff #

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

exist = 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) - 1 - in_A
    for in_B in range(1 << n):
        in_B &= ex_A
        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:
            exist = True
            break
    if exist:
        break

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