結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2020-06-19 13:31:27 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 253 ms / 5,000 ms |
コード長 | 494 bytes |
コンパイル時間 | 74 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 18,560 KB |
最終ジャッジ日時 | 2024-07-03 13:17:33 |
合計ジャッジ時間 | 2,676 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
n = int(input()) W = list(map(int, input().split())) W.sort() s = sum(W) if s % 2 == 1: print("impossible") exit() ss = s//2 dp = [[False]*(s+1) for _ in range(n)] for i in range(n): dp[i][0] = True dp[0][W[0]] = True for i in range(n-1): for j in range(ss+1): if j >= W[i+1]: dp[i+1][j] = dp[i][j-W[i+1]] if dp[i][j]: dp[i+1][j] = True for i in range(n): if dp[i][ss]: print("possible") exit() print("impossible")