結果

問題 No.4 おもりと天秤
ユーザー popketlepopketle
提出日時 2019-12-24 12:18:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 371 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 11,912 KB
実行使用メモリ 18,108 KB
最終ジャッジ日時 2023-10-21 18:33:54
合計ジャッジ時間 3,724 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,368 KB
testcase_01 AC 29 ms
10,112 KB
testcase_02 AC 52 ms
11,336 KB
testcase_03 AC 46 ms
10,980 KB
testcase_04 AC 53 ms
11,344 KB
testcase_05 AC 250 ms
18,056 KB
testcase_06 AC 32 ms
10,348 KB
testcase_07 AC 255 ms
18,056 KB
testcase_08 AC 29 ms
10,140 KB
testcase_09 RE -
testcase_10 AC 258 ms
18,056 KB
testcase_11 AC 41 ms
10,712 KB
testcase_12 AC 34 ms
10,396 KB
testcase_13 AC 34 ms
10,396 KB
testcase_14 AC 35 ms
10,504 KB
testcase_15 AC 34 ms
10,396 KB
testcase_16 AC 41 ms
10,820 KB
testcase_17 AC 41 ms
10,712 KB
testcase_18 AC 216 ms
18,056 KB
testcase_19 AC 244 ms
18,056 KB
testcase_20 AC 257 ms
18,056 KB
testcase_21 AC 242 ms
18,056 KB
testcase_22 AC 244 ms
18,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
W=list(map(int,input().split()))

if sum(W)%2!=0:
  print('impossible')
  exit()
dp=[[False]*(100*101) for _ in range(n+1)]
dp[0][0],dp[0][W[0]]=True,True
for i in range(n):
  for j in range(100*101):
    if dp[i][j]==True:
      dp[i+1][j+W[i]]=True
      dp[i+1][j]=True
if dp[n][int(sum(W)/2)]==True:
    print('possible')
    exit()
print('impossible')
0