結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
HIROPON87069639
|
| 提出日時 | 2016-03-09 21:55:36 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 5,000 ms |
| コード長 | 393 bytes |
| 記録 | |
| コンパイル時間 | 140 ms |
| コンパイル使用メモリ | 76,988 KB |
| 最終ジャッジ日時 | 2025-12-03 19:38:39 |
|
ジャッジサーバー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"
HIROPON87069639