結果
問題 | No.4 おもりと天秤 |
ユーザー | _manji0 |
提出日時 | 2022-01-14 01:31:34 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 653 bytes |
コンパイル時間 | 106 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 51,472 KB |
最終ジャッジ日時 | 2024-04-29 01:00:24 |
合計ジャッジ時間 | 19,490 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 566 ms
44,348 KB |
testcase_01 | AC | 566 ms
43,836 KB |
testcase_02 | AC | 564 ms
44,220 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 563 ms
44,220 KB |
testcase_07 | WA | - |
testcase_08 | AC | 556 ms
44,344 KB |
testcase_09 | AC | 1,430 ms
51,472 KB |
testcase_10 | WA | - |
testcase_11 | AC | 531 ms
44,352 KB |
testcase_12 | AC | 528 ms
43,840 KB |
testcase_13 | AC | 536 ms
43,836 KB |
testcase_14 | AC | 535 ms
43,964 KB |
testcase_15 | AC | 536 ms
44,228 KB |
testcase_16 | WA | - |
testcase_17 | AC | 530 ms
44,220 KB |
testcase_18 | AC | 971 ms
47,900 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
ソースコード
import numpy def main(): N = int(input()) W = [ int(i) for i in input().split() ] su = sum(W) if su % 2 == 1: print("impossible") return su = su // 2 dp = numpy.zeros((N+1, su*2+1)) for i in range(N+1): dp[i][0] = 1 for j in range(1, su*2+1): dp[0][j] = 0 for i in range(1, N+1): for j in range(1, su*2+1): w = W[i-1] if j-w < 0: dp[i][j] = 0 else: dp[i][j] = dp[i-1][j-w] * 1 if dp[N][su]: print("possible") else: print("impossible") if __name__ == "__main__": main()