結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-03-09 21:55:36 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 393 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-06-26 09:26:52 |
合計ジャッジ時間 | 1,417 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
# -*- coding: utf-8 -*- #input N = input() W = map(int, raw_input().split()) if sum(W) % 2 == 1: print "impossible" exit() sumhalf = sum(W) / 2 # dynamic programming DP = [0] * (sumhalf + 100) DP[0] = 1 for w in W: for i in reversed(range(sumhalf)): if DP[i] == 1: DP[i + w] = 1 # output if DP[sumhalf] == 1: print "possible" else: print "impossible"