当前位置:网站首页>P1048 [noip2005 popularization group] Drug collection
P1048 [noip2005 popularization group] Drug collection
2022-06-13 03:01: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;
}
}边栏推荐
- Radio design and implementation in IVI system
- Beginner development process_ Project development FAQs
- Linked list: adding numbers in the linked list
- Rounding in JS
- Techniques for collecting stringgrid
- Perfect square
- Vs Code modify default terminal_ Modify the default terminal opened by vs Code
- Detailed installation tutorial of MATLAB r2019 B-mode ultrasound (complete installation files are attached)
- Image classification system based on support vector machine (Matlab GUI interface version)
- A wechat app for shopping
猜你喜欢

Introduction to facial expression recognition system -- offline environment configuration

A wechat app for shopping

【pytorch 記錄】pytorch的變量parameter、buffer。self.register_buffer()、self.register_parameter()

Six special GPU products for domestic aircraft passed the appraisal and review

Linked list: orderly circular linked list
![[data analysis and visualization] key points of data drawing 11- precautions for radar chart](/img/46/41e4e0fedb3653b119b0e2af836d85.jpg)
[data analysis and visualization] key points of data drawing 11- precautions for radar chart

JS merge multiple string arrays to maintain the original order and remove duplicates

Useful websites for writing papers and studying at ordinary times
![[data analysis and visualization] key points of data drawing 8- use of circular bar chart](/img/1f/232f2f0134867eeec3f1cfe005b2b5.jpg)
[data analysis and visualization] key points of data drawing 8- use of circular bar chart

Linked list: the first coincident node of two linked lists
随机推荐
CDN single page reference of indexbar index column in vant framework cannot be displayed normally
Pytorch record: pytorch variables parameter and buffer. self. register_ buffer()、self. register_ parameter()
2022 qianle micro cloud technology learning task plan
The latest Matlab r2020 B ultrasonic detailed installation tutorial (with complete installation files)
Spark UDF instance details
Summary of innovative ideas of transformer model in CV
Ijkplayer source code ---packetqueue
When the flutter runs the project, the gradle download fails, and the running gradle task 'assemblydebug' is always displayed
Using binary heap to implement priority queue
Entity framework extends the actual combat, small project reconfiguration, no trouble
Linked lists: rearranging linked lists
Linked list: adding numbers in the linked list
wx.createSelectorQuery()在components获取Dom节点的使用
[common tools] pyautogui tutorial
遍历数组,删除某元素,直到删除为止
Ijkplayer source code --- decode
[thoughts in the essay] mourn for development technology expert Mao Xingyun
【pytorch 记录】pytorch的变量parameter、buffer。self.register_buffer()、self.register_parameter()
Prometheus node_ Exporter installs and registers as a service
Node uses post to request req Pit with empty body