結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2020-11-29 19:01:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 49 ms / 5,000 ms |
コード長 | 455 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 82,240 KB |
実行使用メモリ | 61,876 KB |
最終ジャッジ日時 | 2024-09-13 02:04:01 |
合計ジャッジ時間 | 2,125 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
import sys readline = sys.stdin.readline # 総和//2を作れるかを判定 N = int(readline()) W = list(map(int,readline().split())) all = sum(W) if all % 2 == 1: print("impossible") exit(0) A = all // 2 dp = [False] * (A + 1) dp[0] = True for i in range(len(W)): for j in range(len(dp) - 1, -1, -1): if not dp[j]: continue if j + W[i] <= A: dp[j + W[i]] = True if dp[A]: print("possible") else: print("impossible")