結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
uenoku
|
| 提出日時 | 2020-05-01 00:00:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 153 ms / 5,000 ms |
| コード長 | 373 bytes |
| コンパイル時間 | 476 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-12-17 23:13:06 |
| 合計ジャッジ時間 | 3,099 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
N = int(input())
W = list(map(int, input().split(" ")))
S = sum(W)
if S % 2 == 1:
print("impossible")
exit(0)
dp = [False] * (S+1)
dp[0] = True
for j in range(N):
nxt = [False] * (S+1)
for i in range(S):
if dp[i] :
nxt[i+W[j]] = dp[i]
nxt[i] = dp[i]
nxt, dp = dp, nxt
print("impossible" if not dp[S//2] else "possible")
uenoku