結果

問題 No.4 おもりと天秤
コンテスト
ユーザー bellangeldindon
提出日時 2019-05-15 15:33:19
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 80 ms / 5,000 ms
+ 58µs
コード長 444 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 81,024 KB
実行使用メモリ 89,856 KB
最終ジャッジ日時 2026-07-18 19:35:13
合計ジャッジ時間 3,172 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(raw_input())
W = map(int, raw_input().split())
sum = 0
for i in range(0, N):
	sum += W[i]
if sum % 2 == 1: print 'impossible'
else:
	dp = []
	for i in range(0, N+1):
		lst = []
		for j in range(0, sum+1):
			lst.append(False)
		dp.append(lst)
	dp[0][0] = True
	for i in range(0, N):
		for j in range(0, sum+1):
			if dp[i][j]:
				dp[i+1][j] = True
				dp[i+1][j+W[i]] = True
	if dp[N][sum/2]: print 'possible'
	else: print 'impossible'
0