結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
human_cipher
|
| 提出日時 | 2022-01-08 23:44:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 5,000 ms |
| コード長 | 475 bytes |
| コンパイル時間 | 260 ms |
| コンパイル使用メモリ | 82,292 KB |
| 実行使用メモリ | 70,768 KB |
| 最終ジャッジ日時 | 2024-11-14 09:54:31 |
| 合計ジャッジ時間 | 2,286 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
n = int(input())
W = list(map(int,input().split()))
sumW = sum(W)
if sumW % 2 == 0:
dp = [[False] * (sumW+1) for _ in range(n+1)]
dp[0][0] = True
for i in range(n):
for j in range(sum(W)):
if j - W[i] >= 0:
dp[i+1][j] = dp[i][j] or dp[i][j-W[i]]
else:
dp[i+1][j] = dp[i][j]
if dp[n][sumW//2]:
ans = "possible"
else:
ans = "impossible"
else:
ans = "impossible"
print(ans)
human_cipher