解题思路:
注意事项:
参考代码:
T, M = map(int, input().split())
grass_time = []
grass_value = []
for _ in range(M):
this_time, this_value = map(int, input().split())
grass_time.append(this_time)
grass_value.append(this_value)
station = [[0] * (T + 1) for _ in range(M)]
for i in range(M):
for j in range(T + 1):
if grass_time[i] <= j:
station[i][j] = max(station[i - 1][j], grass_value[i] + station[i - 1][j - grass_time[i]])
else:
station[i][j] = station[i - 1][j]
print(station[M - 1][T])
0.0分
0 人评分
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:2498 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:701 |
【偶数求和】 (C++代码)浏览:785 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:530 |
WU-printf基础练习2 (C++代码)浏览:2061 |
关于C语言变量位置的问题浏览:294 |
出圈】指针malloc版浏览:377 |
C二级辅导-温度转换 (C语言代码)浏览:802 |
蛇行矩阵 (C语言代码)浏览:559 |
输出九九乘法表 (C语言代码)浏览:1172 |