結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2019-03-29 18:10:20 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 156 ms / 5,000 ms |
コード長 | 401 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 14,720 KB |
最終ジャッジ日時 | 2024-11-07 01:21:33 |
合計ジャッジ時間 | 2,551 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
n = int(input()) w = list(map(int, input().split(" "))) s = sum(w) if s % 2 == 1: print("impossible") exit() s //= 2 t = [[0]*(s+1) for _ in range(n+1)] t[0][0] = 1 for i in range(n): for j in range(s+1): if t[i][j] == 1: t[i+1][j] = 1 if j + w[i] <= s: t[i+1][j+w[i]] = 1 if t[n][s] == 1: print("possible") else: print("impossible")