結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
human_cipher
|
| 提出日時 | 2022-01-08 23:44:04 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 5,000 ms |
| コード長 | 475 bytes |
| 記録 | |
| コンパイル時間 | 272 ms |
| コンパイル使用メモリ | 84,864 KB |
| 実行使用メモリ | 69,248 KB |
| 最終ジャッジ日時 | 2026-05-09 22:27:39 |
| 合計ジャッジ時間 | 2,078 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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