結果

問題 No.4 おもりと天秤
ユーザー tookunn_1213tookunn_1213
提出日時 2015-08-16 22:27:02
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 6,536 KB
実行使用メモリ 14,384 KB
最終ジャッジ日時 2023-09-25 12:28:13
合計ジャッジ時間 7,350 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,156 KB
testcase_01 AC 12 ms
6,032 KB
testcase_02 AC 391 ms
6,692 KB
testcase_03 AC 12 ms
6,012 KB
testcase_04 AC 234 ms
6,556 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N = int(raw_input())
W = map(int,raw_input().split())
sumw = sum(W)
if sumw % 2  == 1:
	print 'impossible'
else:
	queue = [0,0]
	f = False
	while len(queue) > 0:
		ite,now= queue.pop(0),queue.pop(0)
		if ite >= N and now == sumw / 2:
			f = True
			break
		if ite >= N:continue
		if now > sumw / 2:continue
		queue.append(ite + 1)
		queue.append(now + W[ite])
		queue.append(ite + 1)
		queue.append(now)
	if f:
		print 'possible'
	else:
		print 'impossible'
0