結果

問題 No.4 おもりと天秤
ユーザー daleksprinterdaleksprinter
提出日時 2018-09-02 00:56:10
言語 Python2
(2.7.18)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 7,104 KB
実行使用メモリ 6,664 KB
最終ジャッジ日時 2023-10-21 23:26:19
合計ジャッジ時間 1,684 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,440 KB
testcase_01 AC 11 ms
6,440 KB
testcase_02 AC 11 ms
6,448 KB
testcase_03 AC 11 ms
6,444 KB
testcase_04 AC 11 ms
6,452 KB
testcase_05 AC 65 ms
6,556 KB
testcase_06 AC 10 ms
6,440 KB
testcase_07 AC 65 ms
6,556 KB
testcase_08 AC 10 ms
6,440 KB
testcase_09 AC 92 ms
6,664 KB
testcase_10 AC 70 ms
6,572 KB
testcase_11 AC 10 ms
6,444 KB
testcase_12 AC 10 ms
6,440 KB
testcase_13 AC 9 ms
6,440 KB
testcase_14 AC 10 ms
6,440 KB
testcase_15 AC 9 ms
6,440 KB
testcase_16 AC 11 ms
6,440 KB
testcase_17 AC 10 ms
6,440 KB
testcase_18 AC 57 ms
6,548 KB
testcase_19 AC 56 ms
6,544 KB
testcase_20 AC 57 ms
6,540 KB
testcase_21 AC 53 ms
6,532 KB
testcase_22 AC 56 ms
6,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

arr = map(int,raw_input().split())

accumlate = sum(arr)
if accumlate %2 == 1:
	print 'impossible'
	quit()

dp = [0 for i in range(accumlate/2 + 1)]
dp[0] = 1

for i in arr:
	tmp = dp[::1]
	for j in range(accumlate/2+1):
		if j - i > -1 and dp[j-i] == 1:
			tmp[j] = 1

	dp = tmp[::1]

print 'possible' if dp[accumlate/2] else 'impossible'


0