結果
問題 | No.4 おもりと天秤 |
ユーザー | sjiki |
提出日時 | 2021-08-23 22:21:09 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
WA
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 90 ms |
コンパイル使用メモリ | 10,960 KB |
実行使用メモリ | 7,996 KB |
最終ジャッジ日時 | 2023-08-07 20:31:53 |
合計ジャッジ時間 | 1,456 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 17 ms
7,784 KB |
testcase_02 | AC | 16 ms
7,800 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 15 ms
7,940 KB |
testcase_07 | WA | - |
testcase_08 | AC | 15 ms
7,936 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 15 ms
7,824 KB |
testcase_12 | AC | 15 ms
7,876 KB |
testcase_13 | AC | 16 ms
7,940 KB |
testcase_14 | AC | 15 ms
7,972 KB |
testcase_15 | AC | 15 ms
7,840 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 15 ms
7,768 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
ソースコード
N = int(input()) l = list(map(int, input().split())) sum = 0 for i in l: sum += i def part_sum0(a, A): # 初期化 N = len(a) dp = [[0 for i in range(A + 1)] for j in range(N + 1)] dp[0][0] = 1 # DP for i in range(N): for j in range(A + 1): if a[i] <= j: # i+1番目の数字a[i]を足せるかも dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j] else: # 入る可能性はない dp[i + 1][j] = dp[i][j] return dp[N][A] if isinstance(sum/2, int): test = part_sum0(l,int(sum/2)) if test: print('possible') else: print('impossible') else: print('impossible')