結果

問題 No.4 おもりと天秤
ユーザー ytftytft
提出日時 2022-11-02 14:29:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 379 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 80,920 KB
最終ジャッジ日時 2023-09-24 03:44:45
合計ジャッジ時間 3,083 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,620 KB
testcase_01 AC 73 ms
71,868 KB
testcase_02 AC 77 ms
76,296 KB
testcase_03 AC 76 ms
76,408 KB
testcase_04 AC 86 ms
76,268 KB
testcase_05 AC 89 ms
79,020 KB
testcase_06 AC 73 ms
71,776 KB
testcase_07 AC 87 ms
79,092 KB
testcase_08 AC 72 ms
71,720 KB
testcase_09 AC 88 ms
80,920 KB
testcase_10 AC 86 ms
79,340 KB
testcase_11 AC 76 ms
75,620 KB
testcase_12 AC 72 ms
71,536 KB
testcase_13 AC 73 ms
71,616 KB
testcase_14 AC 74 ms
71,628 KB
testcase_15 AC 75 ms
71,632 KB
testcase_16 AC 76 ms
75,384 KB
testcase_17 AC 73 ms
71,528 KB
testcase_18 AC 90 ms
79,156 KB
testcase_19 AC 85 ms
78,832 KB
testcase_20 AC 84 ms
78,804 KB
testcase_21 AC 84 ms
78,964 KB
testcase_22 AC 83 ms
78,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,copy
input=lambda:sys.stdin.readline().rstrip()
N=int(input())
A=list(map(int,input().split()))
if sum(A)%2:
	print("impossible")
	sys.exit()
targ=sum(A)//2
dp=[[0 for j in range(targ+1)] for i in range(N+1)]
dp[0][0]=1
for i in range(N):
	dp[i+1]=copy.copy(dp[i])
	for j in range(targ+1-A[i]):
		dp[i+1][j+A[i]]|=dp[i][j]
print(["impossible","possible"][dp[N][targ]])
0