結果

問題 No.4 おもりと天秤
ユーザー popketlepopketle
提出日時 2019-12-24 12:21:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 252 ms / 5,000 ms
コード長 367 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 18,004 KB
最終ジャッジ日時 2023-10-21 18:37:58
合計ジャッジ時間 3,795 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
18,004 KB
testcase_01 AC 29 ms
10,132 KB
testcase_02 AC 67 ms
18,004 KB
testcase_03 AC 57 ms
18,004 KB
testcase_04 AC 65 ms
18,004 KB
testcase_05 AC 242 ms
18,004 KB
testcase_06 AC 47 ms
18,004 KB
testcase_07 AC 252 ms
18,004 KB
testcase_08 AC 29 ms
10,132 KB
testcase_09 AC 185 ms
18,004 KB
testcase_10 AC 251 ms
18,004 KB
testcase_11 AC 54 ms
18,004 KB
testcase_12 AC 47 ms
18,004 KB
testcase_13 AC 47 ms
18,004 KB
testcase_14 AC 48 ms
18,004 KB
testcase_15 AC 49 ms
18,004 KB
testcase_16 AC 54 ms
18,004 KB
testcase_17 AC 53 ms
18,004 KB
testcase_18 AC 213 ms
18,004 KB
testcase_19 AC 239 ms
18,004 KB
testcase_20 AC 239 ms
18,004 KB
testcase_21 AC 238 ms
18,004 KB
testcase_22 AC 237 ms
18,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if sum(W)%2!=0:
  print('impossible')
  exit()
dp=[[False]*(10001) for _ in range(101)]
dp[0][0],dp[0][W[0]]=True,True
for i in range(n):
  for j in range(10000):
    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