結果

問題 No.4 おもりと天秤
コンテスト
ユーザー T
提出日時 2025-11-20 12:04:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 470 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2025-11-20 12:04:48
合計ジャッジ時間 2,772 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())  #おもりの数(2≦N≦100)
W = list(map(int,input().split()))  #おもりの重さ(1≦W≦100)
total = sum(W)

if (total % 2 != 0):
	print("impossible")
else:
	target = total//2
	Judge = [False] * (target + 1)
	Judge[0] = True
	
	for w in W:
		for i in range(target,w-1,-1):
			if (Judge[i-w] == True):
				Judge[i] = True
			else:
				pass
			
	if (Judge[target] == True):
		print("possible")
	else:
		print("impossible")
0