結果

問題 No.4 おもりと天秤
ユーザー asumo0729asumo0729
提出日時 2020-12-16 17:03:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 590 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,608 KB
実行使用メモリ 61,656 KB
最終ジャッジ日時 2023-10-20 09:42:06
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,352 KB
testcase_01 AC 40 ms
53,352 KB
testcase_02 AC 46 ms
59,452 KB
testcase_03 AC 44 ms
59,376 KB
testcase_04 AC 46 ms
59,456 KB
testcase_05 AC 50 ms
61,656 KB
testcase_06 AC 40 ms
53,352 KB
testcase_07 AC 51 ms
61,656 KB
testcase_08 AC 39 ms
53,352 KB
testcase_09 AC 47 ms
59,456 KB
testcase_10 AC 50 ms
61,656 KB
testcase_11 AC 43 ms
59,372 KB
testcase_12 AC 39 ms
53,352 KB
testcase_13 AC 40 ms
53,352 KB
testcase_14 AC 40 ms
53,352 KB
testcase_15 AC 40 ms
53,352 KB
testcase_16 AC 44 ms
59,372 KB
testcase_17 AC 40 ms
53,352 KB
testcase_18 AC 50 ms
61,644 KB
testcase_19 AC 52 ms
61,656 KB
testcase_20 AC 51 ms
61,656 KB
testcase_21 AC 51 ms
61,656 KB
testcase_22 AC 52 ms
61,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
stdin=sys.stdin

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
tp=lambda:tuple(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
yp=lambda:print('Yes')
np=lambda:print('No')

n=ip()
w=lp()

s=sum(w)
if s%2==1:
    print('impossible')
else:
    half=s//2
    dp=[-1 for _ in range(half+1)]
    dp[0]=0
    for now in w:
        for i in range(half,-1,-1):
            if i-now>=0 and dp[i-now]!=-1:
                dp[i]=0
    if dp[half]==-1:
        print('impossible')
    else:
        print('possible')



0