結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
mationaruzou
|
| 提出日時 | 2020-06-19 13:31:27 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
AC
|
| 実行時間 | 242 ms / 5,000 ms |
| コード長 | 494 bytes |
| 記録 | |
| コンパイル時間 | 328 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 21,976 KB |
| 最終ジャッジ日時 | 2026-03-24 21:29:45 |
| 合計ジャッジ時間 | 4,216 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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")
mationaruzou