結果

問題 No.4 おもりと天秤
ユーザー ok_adachi_jpok_adachi_jp
提出日時 2017-11-21 17:27:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 444 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 23,216 KB
最終ジャッジ日時 2023-08-17 11:50:49
合計ジャッジ時間 6,815 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,776 KB
testcase_01 AC 16 ms
7,868 KB
testcase_02 AC 31 ms
8,508 KB
testcase_03 AC 16 ms
7,880 KB
testcase_04 AC 17 ms
7,824 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 #

# -*- 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