結果

問題 No.4 おもりと天秤
ユーザー ok_adachi_jp
提出日時 2017-11-21 17:27:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 444 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 32,000 KB
最終ジャッジ日時 2024-11-26 08:15:32
合計ジャッジ時間 61,522 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

def main():

	N = input()
	W = list(map(int, input().split()))

	target = sum(W) / 2
	queue = []
	queue.append(0)

	ans = "impossible"
	for i in W:
		for j in range(len(queue)):
			v = queue[j]
			queue.pop(j)
			num = i + v
			if num == target:
				ans = "possible"
				break
			elif num > target:
				queue.append(v)
			else:
				queue.append(num)
				queue.append(v)

	print(ans)

if __name__ == '__main__':
	main()
0