結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
AEn
|
| 提出日時 | 2022-05-16 16:08:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 5,000 ms |
| コード長 | 450 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 82,028 KB |
| 実行使用メモリ | 83,712 KB |
| 最終ジャッジ日時 | 2024-09-14 08:15:14 |
| 合計ジャッジ時間 | 2,187 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
N = int(input())
W = list(map(int, input().split()))
sm = sum(W)
if sm%2 == 1:
print('impossible')
exit()
dp = [[True]+[False]*sm for _ in range(N)]
dp[0][W[0]] = True
for i in range(1, N):
for j in range(sm+1):
if dp[i-1][j] == True:
dp[i][j] = dp[i-1][j]
if j - W[i] >= 0 and dp[i-1][j-W[i]]==True:
dp[i][j] = dp[i-1][j-W[i]]
if dp[-1][sm//2]:
print('possible')
else:
print('impossible')
AEn