結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
10,368 KB
testcase_01 AC 30 ms
10,108 KB
testcase_02 AC 56 ms
11,304 KB
testcase_03 AC 46 ms
10,944 KB
testcase_04 AC 54 ms
11,304 KB
testcase_05 AC 252 ms
17,980 KB
testcase_06 AC 35 ms
10,320 KB
testcase_07 AC 260 ms
17,980 KB
testcase_08 AC 31 ms
10,108 KB
testcase_09 RE -
testcase_10 AC 259 ms
17,980 KB
testcase_11 AC 40 ms
10,680 KB
testcase_12 AC 34 ms
10,368 KB
testcase_13 AC 34 ms
10,368 KB
testcase_14 AC 37 ms
10,476 KB
testcase_15 AC 35 ms
10,368 KB
testcase_16 AC 43 ms
10,788 KB
testcase_17 AC 40 ms
10,680 KB
testcase_18 AC 219 ms
17,980 KB
testcase_19 AC 252 ms
17,980 KB
testcase_20 AC 251 ms
17,980 KB
testcase_21 AC 239 ms
17,980 KB
testcase_22 AC 245 ms
17,980 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+1)]
dp[0][0]=True
for i in range(n):
  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