結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
yassu0320
|
| 提出日時 | 2021-07-11 12:16:36 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,296 bytes |
| コンパイル時間 | 108 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2024-07-02 03:02:17 |
| 合計ジャッジ時間 | 2,975 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 3 |
ソースコード
#!/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()
yassu0320