結果

問題 No.4 おもりと天秤
ユーザー mediocreRail
提出日時 2023-08-15 08:33:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 839 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-11-23 14:24:50
合計ジャッジ時間 3,047 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect,collections,itertools,math,functools,heapq
import sys
#sys.setrecursionlimit(10**6)
def I(): return int(sys.stdin.readline().rstrip())
def IN(): return int(input())
def LIN(): return list(map(int, input().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LF(): return list(map(float,sys.stdin.readline().rstrip().split()))
def SI(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

"""
方針
dp
"""

N=I()
W=LI()
W.sort()
sa = sum(W)
if sa%2!=0:
    print('impossible')
    exit()

dp = [False]*(11000)
dp[0] = True
for i in range(N):
    w = W[i]
    np = dp.copy()
    for j in range(10050):
        if dp[j]:
            np[j] = True
            np[w+j] = True
    dp = np
if dp[N//2]:
    print('possible')
else:
    print('impossible')
0