結果

問題 No.4 おもりと天秤
ユーザー tabataba
提出日時 2016-04-12 23:25:10
言語 Python2
(2.7.18)
結果
AC  
実行時間 267 ms / 5,000 ms
コード長 330 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 6,588 KB
実行使用メモリ 6,484 KB
最終ジャッジ日時 2023-09-08 16:38:34
合計ジャッジ時間 2,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,116 KB
testcase_01 AC 11 ms
5,952 KB
testcase_02 AC 14 ms
6,040 KB
testcase_03 AC 13 ms
6,108 KB
testcase_04 AC 15 ms
6,040 KB
testcase_05 AC 148 ms
6,168 KB
testcase_06 AC 11 ms
6,036 KB
testcase_07 AC 154 ms
6,328 KB
testcase_08 AC 12 ms
5,948 KB
testcase_09 AC 267 ms
6,484 KB
testcase_10 AC 166 ms
6,200 KB
testcase_11 AC 11 ms
5,956 KB
testcase_12 AC 11 ms
6,136 KB
testcase_13 AC 11 ms
5,948 KB
testcase_14 AC 11 ms
6,060 KB
testcase_15 AC 11 ms
6,036 KB
testcase_16 AC 12 ms
5,952 KB
testcase_17 AC 12 ms
6,100 KB
testcase_18 AC 142 ms
6,248 KB
testcase_19 AC 136 ms
6,340 KB
testcase_20 AC 134 ms
6,296 KB
testcase_21 AC 127 ms
6,236 KB
testcase_22 AC 131 ms
6,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=input()
w=sorted(map(int,raw_input().split()))[::-1]
s=sum(w)
if s&1:
	print"impossible"
	exit()
s/=2
if s in w:
	print"possible"
	exit()
t=[0]*(s+1)
for i in range(n):
	nt=t[:]
	tw=w[i]
	for j in range(s):
		if j+tw<=s and t[j]+tw<=s:
			nt[j+tw]=max(t[j+tw],t[j]+tw)
	t=nt
#print t
#print s
print["im",""][s==t[-1]]+"possible"
0