結果

問題 No.4 おもりと天秤
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-11-28 07:26:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 581 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 64,524 KB
最終ジャッジ日時 2024-04-15 09:45:32
合計ジャッジ時間 2,503 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
62,076 KB
testcase_01 AC 49 ms
57,280 KB
testcase_02 AC 55 ms
64,524 KB
testcase_03 AC 58 ms
63,876 KB
testcase_04 AC 54 ms
63,460 KB
testcase_05 AC 64 ms
62,800 KB
testcase_06 AC 51 ms
61,316 KB
testcase_07 AC 60 ms
62,936 KB
testcase_08 AC 50 ms
56,052 KB
testcase_09 AC 58 ms
63,900 KB
testcase_10 AC 60 ms
63,272 KB
testcase_11 AC 53 ms
62,048 KB
testcase_12 AC 53 ms
61,664 KB
testcase_13 AC 52 ms
61,900 KB
testcase_14 AC 54 ms
62,912 KB
testcase_15 AC 55 ms
62,980 KB
testcase_16 AC 54 ms
61,580 KB
testcase_17 AC 55 ms
62,980 KB
testcase_18 AC 59 ms
63,744 KB
testcase_19 AC 62 ms
62,864 KB
testcase_20 AC 59 ms
63,252 KB
testcase_21 AC 60 ms
63,320 KB
testcase_22 AC 61 ms
63,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from functools import *
from itertools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
W = list(map(int,input().split()))
S = sum(W)
if S%2:
    print('impossible')
    exit()
    
T = S//2
M = 10**4+2
dp = [False]*M
dp[0]=True
dp[W[0]]=True
def f(x):
    return min(x,M-1)
for i in range(N-1):
    w = W[i+1]
    for j in range(M-1,-1,-1):
        if dp[j]:
            dp[f(j+w)]=True
if dp[T]:
    print('possible')
else:
    print('impossible')
0