当前位置:网站首页>P1048 [noip2005 popularization group] Drug collection
P1048 [noip2005 popularization group] Drug collection
2022-06-13 03:25:00 【Python's path to becoming a God】
Title Description
Chen Chen is a gifted child , His dream is to become the greatest doctor in the world . So , He wants to learn from the most prestigious doctor in the neighborhood . In order to judge his qualifications , Gave him a problem . The doctor took him to a cave full of herbs and said :“ children , There are some different herbs in this cave , It takes time to pick each one , Each has its own value . I'll give you a period of time , In the meantime , You can pick some herbs . If you are a smart kid , You should be able to maximize the total value of the herbs you pick .”
If you are Chen Chen , Can you finish the task ?
Input format
The first line has 2 It's an integer T(1≤T≤1000) and M(1≤M≤100), Separated by a space ,T Represents the total time that can be used to collect medicine ,M Represents the number of herbs in the cave .
Next M Each line consists of two in 1 To 100 Between ( Include 1 and 100) The integer of , It means the time of picking a herb and the value of the herb .
Output format
Output the maximum total value of herbs that can be collected within the specified time .
I/o sample
Input #1
70 3 71 100 69 1 1 2
Output #1
3
explain / Tips
【 Data range 】
- about 30% The data of ,0M≤10;
- For all the data ,0M≤100.
【 Title source 】
NOIP 2005 Third question of popularization group
#include<bits/stdc++.h>
using namespace std;
int T,M;
int v[10001],w[10001];
int dp[10001][10001];
int main()
{
while(cin>>T>>M){
for(int i=1;i<=M;i++)
cin>>w[i]>>v[i];
for(int i=1;i<=M;i++)
for(int j=1;j<=T;j++){
if(w[i]>j)
dp[i][j]=dp[i-1][j];
else
dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
}
cout<<dp[M][T]<<endl;
}
}边栏推荐
- Several functions in YAF framework controller
- MySQL index bottom layer (I)
- C method parameter: params
- C语言程序设计——从键盘任意输入一个字符串,计算其实际字符个数并打印输出,要求不能使用字符串处理函数strlen(),使用自定义子函数Mystrlen()实现计算字符个数的功能。
- MASA Auth - 从用户的角度看整体设计
- Introduction to redis (using redis, common commands, persistence methods, and cluster operations)
- Unified scheduling and management of dataX tasks through web ETL
- Azure SQL db/dw series (12) -- using query store (1) -- report Introduction (1)
- C simple understanding - generics
- Level II C preparation -- basic concepts of program design
猜你喜欢

Panel for measuring innovation efficiency of 31 provinces in China (using Malmquist method)
![Loading process of [JVM series 3] classes](/img/a7/707c5cb95de71d95bf6ad9b2f69afa.jpg)
Loading process of [JVM series 3] classes

(九)详解广播机制

Review notes of RS data communication foundation STP
![[JVM series 8] overview of JVM knowledge points](/img/e5/902de6398359b75183aa1fafcaa7d1.jpg)
[JVM series 8] overview of JVM knowledge points

Spoon database insert table operation
![[JVM Series 7] garbage collector](/img/e5/902de6398359b75183aa1fafcaa7d1.jpg)
[JVM Series 7] garbage collector

Time processing class in PHP

Azure SQL db/dw series (14) -- using query store (3) -- common scenarios

Summary of virtualization technology development
随机推荐
Reading notes of effective managers
Common command records of redis client
2-year experience summary to tell you how to do a good job in project management
Differences between XAML and XML
C method parameter: ref
Introduction to redis (using redis, common commands, persistence methods, and cluster operations)
Implode and explode in golang
English语法_方式副词-位置
2022.05.29
C # simple understanding - method overloading and rewriting
MySQL and PostgreSQL installation subtotal
技术博客,经验分享宝典
Open source - campus forum and resource sharing applet
Dish recommendation system based on graph database
C method parameter: out
Capital digit to number format
[azure data platform] ETL tool (6) -- re understanding azure data factory
C method parameter: params
Querywrapper constructor method
MASA Auth - 从用户的角度看整体设计