結果

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

ソースコード

diff #
raw source code

n=input()
w=sorted(map(int,raw_input().split()))[::-1]
s=sum(w)
if s&1:
	print"impossible"
	exit()
s/=2
def solve(a,b):
	if a>=n:
		return False
	c=b+w[a]
	if c>s:
		return solve(a+1,b)
	if c==s:
		return True
	d=solve(a+1,c)
	if d==False:
		return solve(a+1,b)
	return True
print["im",""][solve(0,0)]+"possible"
0