menu ZJOJ
account_circle 请登录
home
首页
book
题目
apps
分类
play_circle_outline
状态
assessment
竞赛
assignment
作业
equalizer
排名
assignment_ind
登录
person_add
注册
1560: 小紫的梦想
时间限制:1.000s
内存限制:128MB

题目描述

小紫是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带到一个到处都是草药的山洞里对他说:“孩子,这个山洞里有一些不同的草药,采每一株都需要一些时间,每一株也有它自身的价值。我会给你一段时间,在这段时间里,你可以采到一些草药。如果你是一个聪明的孩子,你应该可以让采到的草药的总价值最大。”

如果你是小紫,你能完成这个任务吗?

第一行有 lns="http://www.w3.org/1998/Math/MathML">2 个整数 lns="http://www.w3.org/1998/Math/MathML">Tlns="http://www.w3.org/1998/Math/MathML">1 \le T \le 1000)和 lns="http://www.w3.org/1998/Math/MathML">Mlns="http://www.w3.org/1998/Math/MathML">1 \le M \le 100),用一个空格隔开,lns="http://www.w3.org/1998/Math/MathML">T 代表总共能够用来采药的时间,lns="http://www.w3.org/1998/Math/MathML">M 代表山洞里的草药的数目。

接下来的 lns="http://www.w3.org/1998/Math/MathML">M 行每行包括两个在 lns="http://www.w3.org/1998/Math/MathML">1 到 lns="http://www.w3.org/1998/Math/MathML">100 之间(包括 lns="http://www.w3.org/1998/Math/MathML">1 和 lns="http://www.w3.org/1998/Math/MathML">100)的整数,分别表示采摘某株草药的时间和这株草药的价值。

输入格式

第一行有 lns="http://www.w3.org/1998/Math/MathML">2 个整数 lns="http://www.w3.org/1998/Math/MathML">Tlns="http://www.w3.org/1998/Math/MathML">1 \le T \le 1000)和 lns="http://www.w3.org/1998/Math/MathML">Mlns="http://www.w3.org/1998/Math/MathML">1 \le M \le 100),用一个空格隔开,lns="http://www.w3.org/1998/Math/MathML">T 代表总共能够用来采药的时间,lns="http://www.w3.org/1998/Math/MathML">M 代表山洞里的草药的数目。

接下来的 lns="http://www.w3.org/1998/Math/MathML">M 行每行包括两个在 lns="http://www.w3.org/1998/Math/MathML">1 到 lns="http://www.w3.org/1998/Math/MathML">100 之间(包括 lns="http://www.w3.org/1998/Math/MathML">1 和 lns="http://www.w3.org/1998/Math/MathML">100)的整数,分别表示采摘某株草药的时间和这株草药的价值。

输出格式

输出在规定的时间内可以采到的草药的最大总价值。

样例输入 content_copy

70 3
71 100
69 1
1 2

样例输出 content_copy

3

分类