結果

問題 No.527 ナップサック容量問題
ユーザー 双六双六
提出日時 2020-08-26 15:46:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 221,312 KB
最終ジャッジ日時 2024-04-25 02:24:57
合計ジャッジ時間 8,084 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
66,432 KB
testcase_01 AC 66 ms
67,840 KB
testcase_02 AC 58 ms
64,512 KB
testcase_03 AC 63 ms
67,840 KB
testcase_04 AC 59 ms
63,360 KB
testcase_05 AC 147 ms
125,952 KB
testcase_06 AC 263 ms
197,120 KB
testcase_07 WA -
testcase_08 AC 129 ms
116,736 KB
testcase_09 AC 56 ms
63,616 KB
testcase_10 WA -
testcase_11 AC 193 ms
157,568 KB
testcase_12 AC 156 ms
131,328 KB
testcase_13 AC 274 ms
201,472 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 63 ms
67,968 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 66 ms
69,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 103 ms
93,952 KB
testcase_25 AC 201 ms
164,096 KB
testcase_26 WA -
testcase_27 AC 191 ms
154,752 KB
testcase_28 AC 171 ms
142,592 KB
testcase_29 AC 304 ms
220,032 KB
testcase_30 AC 74 ms
76,032 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 60 ms
66,432 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

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())
	DP = [[-INF for i in range(100001)] for j in range(N + 1)]
	DP[0][0] = 0
	for i in range(N):
		v, w = getlist()
		for j in range(100001):
			if DP[i][j] != -INF:
				DP[i + 1][j] = DP[i][j]
				DP[i + 1][j + w] = max(DP[i + 1][j + w], DP[i][j] + v)

	V = int(input())
	m = INF
	M = INF
	for i in range(100001):
		if DP[-1][i] >= V:
			m = min(m, i)

		if DP[-1][i] > V and M == INF:
			M = i - 1

	m = max(1, m)
	if M == INF:
		M = "inf"

	print(m)
	print(M)

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