結果
問題 |
No.1594 Three Classes
|
ユーザー |
![]() |
提出日時 | 2025-03-26 15:43:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 946 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 64,256 KB |
最終ジャッジ日時 | 2025-03-26 15:43:59 |
合計ジャッジ時間 | 2,141 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
import sys n = int(sys.stdin.readline()) E = list(map(int, sys.stdin.readline().split())) sum_total = sum(E) if sum_total % 3 != 0: print("No") else: S = sum_total // 3 found = False for maskA in range(1, 1 << n): sumA = 0 for i in range(n): if maskA & (1 << i): sumA += E[i] if sumA != S: continue remaining = [] for i in range(n): if not (maskA & (1 << i)): remaining.append(E[i]) if len(remaining) < 2: continue possible_sums = {0} for num in remaining: new_sums = set() for s in possible_sums: new_s = s + num new_sums.add(new_s) possible_sums.update(new_sums) if S in possible_sums: found = True break print("Yes" if found else "No")