結果

問題 No.1594 Three Classes
ユーザー 大橋佐和大橋佐和
提出日時 2022-05-06 21:22:49
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 584 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 77,140 KB
最終ジャッジ日時 2023-08-10 07:14:33
合計ジャッジ時間 3,684 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
76,928 KB
testcase_01 AC 67 ms
71,204 KB
testcase_02 AC 66 ms
71,388 KB
testcase_03 AC 87 ms
76,372 KB
testcase_04 AC 156 ms
76,892 KB
testcase_05 AC 159 ms
76,896 KB
testcase_06 AC 89 ms
76,376 KB
testcase_07 AC 89 ms
76,484 KB
testcase_08 AC 156 ms
76,852 KB
testcase_09 AC 156 ms
76,792 KB
testcase_10 AC 158 ms
76,928 KB
testcase_11 AC 159 ms
76,988 KB
testcase_12 AC 159 ms
77,140 KB
testcase_13 AC 72 ms
71,108 KB
testcase_14 AC 114 ms
76,804 KB
testcase_15 AC 83 ms
76,348 KB
testcase_16 AC 87 ms
76,288 KB
testcase_17 AC 82 ms
76,564 KB
testcase_18 AC 71 ms
71,116 KB
testcase_19 AC 75 ms
76,612 KB
testcase_20 AC 82 ms
76,648 KB
権限があれば一括ダウンロードができます

ソースコード

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