結果

問題 No.4 おもりと天秤
ユーザー RuteRute
提出日時 2021-06-30 15:37:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 489 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 10,836 KB
実行使用メモリ 16,396 KB
最終ジャッジ日時 2023-09-09 08:33:39
合計ジャッジ時間 3,870 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,892 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 21 ms
8,240 KB
testcase_03 AC 18 ms
7,872 KB
testcase_04 AC 22 ms
8,240 KB
testcase_05 AC 233 ms
12,832 KB
testcase_06 AC 15 ms
7,800 KB
testcase_07 AC 235 ms
12,856 KB
testcase_08 AC 16 ms
7,808 KB
testcase_09 AC 525 ms
16,396 KB
testcase_10 AC 251 ms
13,412 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 15 ms
7,844 KB
testcase_14 AC 16 ms
7,856 KB
testcase_15 AC 16 ms
7,856 KB
testcase_16 AC 16 ms
7,796 KB
testcase_17 AC 16 ms
7,904 KB
testcase_18 AC 241 ms
12,328 KB
testcase_19 AC 209 ms
12,168 KB
testcase_20 AC 206 ms
12,256 KB
testcase_21 AC 194 ms
11,884 KB
testcase_22 AC 213 ms
12,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = [0] + list(map(int,input().split()))
P = sum(W)
if P % 2 == 1:
  print("impossible")
else:
  dp = [[0 for i in range(P+1)]for j in range(N+1)]
  for i in range(N):
    dp[i][0] = 1
  for i in range(1,N+1):
    for j in range(1,P+1):
      if j >= W[i] and dp[i][j-W[i]] == 1:
        dp[i][j] = 1
      else:
          dp[i][j] = dp[i-1][j]
  f = 0
  for i in range(1,N+1):
    if dp[i][P//2]:
      f += 1
  if f:
    print("possible")
  else:
    print("impossible")
0