結果

問題 No.4 おもりと天秤
ユーザー tookunn_1213tookunn_1213
提出日時 2015-08-16 23:00:46
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 491 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 6,660 KB
実行使用メモリ 10,528 KB
最終ジャッジ日時 2023-09-25 12:28:22
合計ジャッジ時間 7,221 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,964 KB
testcase_01 AC 12 ms
5,812 KB
testcase_02 AC 24 ms
5,980 KB
testcase_03 AC 11 ms
5,924 KB
testcase_04 AC 11 ms
5,984 KB
testcase_05 AC 11 ms
5,844 KB
testcase_06 AC 11 ms
5,976 KB
testcase_07 AC 12 ms
5,932 KB
testcase_08 AC 11 ms
5,984 KB
testcase_09 AC 11 ms
5,884 KB
testcase_10 AC 12 ms
6,032 KB
testcase_11 AC 11 ms
5,952 KB
testcase_12 AC 11 ms
5,852 KB
testcase_13 AC 11 ms
6,000 KB
testcase_14 AC 12 ms
5,852 KB
testcase_15 AC 11 ms
5,860 KB
testcase_16 AC 12 ms
5,972 KB
testcase_17 AC 12 ms
5,952 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(i,Sum,N,W,sumW,found):
	if found >= 1:return found
	if Sum > sumW / 2:return found
	if i == N and Sum == sumW / 2:
		found += 1
		return found
	if i >= N:return found
	found += dfs(i + 1,Sum + W[i],N,W,sumW,found)
	found += dfs(i + 1,Sum,N,W,sumW,found)
	return found
if  __name__ == '__main__':
	N = int(raw_input())
	W = map(int,raw_input().split())
	if sum(W) % 2 == 0:
		if dfs(0,0,N,W,sum(W),0) >= 1:
			print 'possible'
		else:
			print 'impossible'
	else:
		print 'impossible'
0