解题思路:
注意事项:
参考代码:
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语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:939 |
妹子杀手的故事 (C语言代码)浏览:690 |
回文数(一) (C语言代码)浏览:744 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:751 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:584 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:1058 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:639 |
三角形 (C语言代码)浏览:914 |
C语言训练-亲密数 (C语言代码)浏览:682 |
Cylinder (C语言描述,蓝桥杯)浏览:1247 |