結果

問題 No.1594 Three Classes
ユーザー IgrmiIgrmi
提出日時 2021-07-09 21:47:41
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 76,604 KB
最終ジャッジ日時 2023-08-10 06:49:17
合計ジャッジ時間 2,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
76,188 KB
testcase_01 AC 66 ms
71,368 KB
testcase_02 AC 68 ms
71,536 KB
testcase_03 AC 76 ms
76,556 KB
testcase_04 AC 70 ms
71,488 KB
testcase_05 AC 73 ms
76,424 KB
testcase_06 AC 74 ms
76,356 KB
testcase_07 AC 73 ms
76,372 KB
testcase_08 AC 73 ms
76,576 KB
testcase_09 AC 74 ms
76,360 KB
testcase_10 AC 72 ms
76,312 KB
testcase_11 AC 72 ms
76,468 KB
testcase_12 AC 74 ms
76,136 KB
testcase_13 AC 68 ms
71,460 KB
testcase_14 AC 72 ms
76,376 KB
testcase_15 AC 73 ms
76,132 KB
testcase_16 AC 75 ms
76,604 KB
testcase_17 AC 74 ms
76,352 KB
testcase_18 AC 68 ms
71,088 KB
testcase_19 AC 68 ms
71,244 KB
testcase_20 AC 73 ms
76,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
E = list(map(int, input().split()))
P = sum(E)
if P % 3:
    print('No')
    exit()
P //= 3
Group = []
GroupSet = set()
for i in range(1 << N):
    p = 0
    for j in range(N):
        if i >> j & 1: p += E[j]
    if p == P:
        Group.append(i)
        GroupSet.add(i)
All = (1 << N) - 1
for i in range(len(Group)):
    for j in range(i):
        if Group[i] & Group[j] == 0 and All - Group[i] - Group[j] in GroupSet:
            print('Yes')
            exit()
print('No')
0