結果

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

ソースコード

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