結果

問題 No.4 おもりと天秤
コンテスト
ユーザー tookunn_1213
提出日時 2015-08-16 22:27:02
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 469 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 129 ms
コンパイル使用メモリ 77,472 KB
最終ジャッジ日時 2025-12-03 16:15:39
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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