結果

問題 No.4 おもりと天秤
ユーザー 双六双六
提出日時 2020-07-25 23:36:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 103 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 76,804 KB
最終ジャッジ日時 2023-09-10 02:12:06
合計ジャッジ時間 4,093 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
76,320 KB
testcase_01 AC 93 ms
71,732 KB
testcase_02 AC 100 ms
76,712 KB
testcase_03 AC 99 ms
76,492 KB
testcase_04 AC 99 ms
76,520 KB
testcase_05 AC 103 ms
76,796 KB
testcase_06 AC 97 ms
76,640 KB
testcase_07 AC 102 ms
76,588 KB
testcase_08 AC 94 ms
71,988 KB
testcase_09 AC 103 ms
76,528 KB
testcase_10 AC 103 ms
76,704 KB
testcase_11 AC 96 ms
76,368 KB
testcase_12 AC 98 ms
76,640 KB
testcase_13 AC 96 ms
76,692 KB
testcase_14 AC 98 ms
76,368 KB
testcase_15 AC 97 ms
76,548 KB
testcase_16 AC 96 ms
76,804 KB
testcase_17 AC 97 ms
76,584 KB
testcase_18 AC 102 ms
76,776 KB
testcase_19 AC 103 ms
76,616 KB
testcase_20 AC 102 ms
76,696 KB
testcase_21 AC 103 ms
76,760 KB
testcase_22 AC 103 ms
76,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	W = getlist()
	s = sum(W)
	if s % 2 == 1:
		print("impossible")
		return

	s = int(s // 2)
	DP = [0] * (10 ** 4 + 1)
	DP[0] = 1
	for i in range(N):
		for j in range(10 ** 4, -1, -1):
			if DP[j] == 1:
				DP[j + W[i]] = 1

	if DP[s] == 1:
		print("possible")
	else:
		print("impossible")


if __name__ == '__main__':
	main()
0