結果

問題 No.4 おもりと天秤
ユーザー qibqib
提出日時 2022-10-21 21:48:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 202 ms / 5,000 ms
コード長 316 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 80,688 KB
最終ジャッジ日時 2023-09-13 22:07:14
合計ジャッジ時間 5,441 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,588 KB
testcase_01 AC 96 ms
71,588 KB
testcase_02 AC 104 ms
77,112 KB
testcase_03 AC 95 ms
71,388 KB
testcase_04 AC 113 ms
77,536 KB
testcase_05 AC 196 ms
80,160 KB
testcase_06 AC 94 ms
71,792 KB
testcase_07 AC 197 ms
80,020 KB
testcase_08 AC 111 ms
77,760 KB
testcase_09 AC 110 ms
78,060 KB
testcase_10 AC 202 ms
80,084 KB
testcase_11 AC 95 ms
71,624 KB
testcase_12 AC 94 ms
71,752 KB
testcase_13 AC 95 ms
71,772 KB
testcase_14 AC 95 ms
71,384 KB
testcase_15 AC 94 ms
71,680 KB
testcase_16 AC 95 ms
71,624 KB
testcase_17 AC 94 ms
71,748 KB
testcase_18 AC 171 ms
79,212 KB
testcase_19 AC 191 ms
79,920 KB
testcase_20 AC 190 ms
80,688 KB
testcase_21 AC 192 ms
80,316 KB
testcase_22 AC 197 ms
79,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

_ = input()
w = list(map(int, input().split()))

dp = defaultdict(int)
dp[w.pop()] += 1
for i in range(len(w)):
  ndp = defaultdict(int)
  for x, v in dp.items():
  	ndp[x + w[i]] += v
  	ndp[x - w[i]] += v
  dp = ndp

if dp[0] > 0:
  print("possible")
else:
	print("impossible")
0