結果

問題 No.4 おもりと天秤
ユーザー popketlepopketle
提出日時 2019-12-24 11:53:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 396 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 11,832 KB
実行使用メモリ 17,868 KB
最終ジャッジ日時 2023-10-21 18:01:14
合計ジャッジ時間 3,760 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,312 KB
testcase_01 AC 31 ms
10,108 KB
testcase_02 AC 57 ms
11,252 KB
testcase_03 AC 45 ms
10,832 KB
testcase_04 AC 53 ms
11,252 KB
testcase_05 AC 255 ms
17,868 KB
testcase_06 AC 34 ms
10,232 KB
testcase_07 AC 262 ms
17,868 KB
testcase_08 AC 30 ms
10,108 KB
testcase_09 RE -
testcase_10 AC 258 ms
17,868 KB
testcase_11 AC 41 ms
10,624 KB
testcase_12 AC 35 ms
10,312 KB
testcase_13 AC 33 ms
10,312 KB
testcase_14 AC 35 ms
10,364 KB
testcase_15 AC 33 ms
10,312 KB
testcase_16 AC 40 ms
10,676 KB
testcase_17 AC 40 ms
10,624 KB
testcase_18 AC 219 ms
17,868 KB
testcase_19 AC 250 ms
17,868 KB
testcase_20 AC 243 ms
17,868 KB
testcase_21 AC 240 ms
17,868 KB
testcase_22 AC 239 ms
17,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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