結果

問題 No.1594 Three Classes
ユーザー IgrmiIgrmi
提出日時 2021-07-09 21:47:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 61,560 KB
最終ジャッジ日時 2024-04-28 00:07:26
合計ジャッジ時間 1,632 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
60,296 KB
testcase_01 AC 35 ms
52,816 KB
testcase_02 AC 37 ms
52,264 KB
testcase_03 AC 43 ms
59,800 KB
testcase_04 AC 38 ms
53,272 KB
testcase_05 AC 41 ms
60,628 KB
testcase_06 AC 42 ms
61,560 KB
testcase_07 AC 41 ms
59,796 KB
testcase_08 AC 40 ms
60,932 KB
testcase_09 AC 37 ms
60,340 KB
testcase_10 AC 40 ms
60,244 KB
testcase_11 AC 40 ms
59,672 KB
testcase_12 AC 41 ms
61,256 KB
testcase_13 AC 35 ms
52,660 KB
testcase_14 AC 42 ms
61,204 KB
testcase_15 AC 41 ms
60,452 KB
testcase_16 AC 40 ms
59,744 KB
testcase_17 AC 42 ms
60,068 KB
testcase_18 AC 37 ms
52,740 KB
testcase_19 AC 33 ms
53,068 KB
testcase_20 AC 40 ms
60,652 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