結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
silversmith
|
| 提出日時 | 2019-05-03 19:46:44 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 957 ms / 5,000 ms |
| + 815µs | |
| コード長 | 516 bytes |
| 記録 | |
| コンパイル時間 | 196 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2026-10-09 23:51:38 |
| 合計ジャッジ時間 | 6,771 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
N = int(input())
W = list(map(int,input().split()))
c_idx = sum(W)
dp = [False] * (2 * c_idx)
dp[c_idx + W[0]] = True
dp[c_idx - W[0]] = True
dp2 = [False] * len(dp)
for i in range(N -1):
for x in range(2* c_idx):
if x < W[i+1]:
dp2[x] = dp[x + W[i+1]]
elif x + W[i+1] > len(dp) -1:
dp2[x] = dp[x - W[i+1]]
else:
dp2[x] = dp[x + W[i+1]] or dp[x - W[i+1]]
dp, dp2 = dp2, dp
if dp[c_idx] == True:
print('possible')
else:
print('impossible')
silversmith