結果
問題 | No.4 おもりと天秤 |
ユーザー | yassu0320 |
提出日時 | 2021-07-11 12:16:36 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,296 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 11,064 KB |
実行使用メモリ | 13,636 KB |
最終ジャッジ日時 | 2023-09-14 20:08:30 |
合計ジャッジ時間 | 3,056 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
9,828 KB |
testcase_01 | AC | 31 ms
9,820 KB |
testcase_02 | AC | 35 ms
9,856 KB |
testcase_03 | AC | 33 ms
9,832 KB |
testcase_04 | AC | 33 ms
9,880 KB |
testcase_05 | AC | 131 ms
11,820 KB |
testcase_06 | AC | 30 ms
9,824 KB |
testcase_07 | AC | 135 ms
11,820 KB |
testcase_08 | AC | 31 ms
9,824 KB |
testcase_09 | AC | 224 ms
13,636 KB |
testcase_10 | AC | 148 ms
12,164 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 31 ms
9,864 KB |
testcase_14 | WA | - |
testcase_15 | AC | 31 ms
9,872 KB |
testcase_16 | AC | 31 ms
9,948 KB |
testcase_17 | AC | 30 ms
9,808 KB |
testcase_18 | AC | 127 ms
11,804 KB |
testcase_19 | AC | 121 ms
11,836 KB |
testcase_20 | AC | 122 ms
11,716 KB |
testcase_21 | AC | 113 ms
11,532 KB |
testcase_22 | AC | 117 ms
11,636 KB |
ソースコード
#!/usr/bin/env python3 from sys import setrecursionlimit, stdin from typing import Dict, Iterable, Set INF: int = 2**62 MOD: int = 10**9 + 7 setrecursionlimit(10**6) def inputs(type_=int): ins = input().split(' ') ins = [x for x in ins if x != ''] if isinstance(type_, Iterable): return [t(x) for t, x in zip(type_, ins)] else: return list(map(type_, ins)) def input_(type_=int): a, = inputs(type_) return a inputi = input_ def inputstr(): return input_(str) # b/aの切り上げ def ceil(b, a): return (a + b - 1) // a def answer(res) -> None: print(res) exit() def compute(): return def main(): n = inputi() ws = inputs() if sum(ws) %2 == 1: print('impossible') exit() target = sum(ws) // 2 ws = [0] + ws n += 1 dp = [[False] * (target+1) for _ in range(n)] dp[0][0] = True for i in range(1, n): for j in range(target + 1): dp[i][j] = dp[i-1][j] if j >= ws[i] and j - ws[i] <= target: dp[i][j] = max(dp[i-1][j], dp[i][j-ws[i]]) else: dp[i][j] = dp[i-1][j] if dp[-1][target]: print('possible') else: print('impossible') if __name__ == '__main__': main()