結果

問題 No.4 おもりと天秤
ユーザー tookunn_1213
提出日時 2015-08-16 22:27:02
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 17,308 KB
最終ジャッジ日時 2024-07-18 09:55:15
合計ジャッジ時間 7,416 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

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