結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2016-08-27 23:37:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 139 ms / 5,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-06-26 09:58:43 |
合計ジャッジ時間 | 2,390 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
import sys, copy if __name__ == '__main__': n = int(input()) weights = [int(token) for token in input().split(' ')] total = sum(weights) if total % 2 != 0: print("impossible") sys.exit(0) dest = total // 2 ht = {} for weight in weights: temp = copy.deepcopy(ht) for ky in ht: temp[ky + weight] = True temp[weight] = True ht = temp if dest in ht: break print("possible" if dest in ht else "impossible")