当前位置:网站首页>背包模型 AcWing 423. 采药
背包模型 AcWing 423. 采药
2022-07-27 10:35:00 【T_Y_F666】
背包模型 AcWing 423. 采药
原题链接
算法标签
DP 01背包问题
思路
代码
#include<bits/stdc++.h>
#define int long long
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 1005;
// f[i]存储所用时间为i时, 采到的草药的最大总价值。
int f[N];
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=read(), m=read();
int ans=0;
rep(i, 0, m){
int tt=read(), v=read();
Rep(j, t, tt){
f[j]=max(f[j], f[j-tt]+v);
}
}
printf("%lld", f[t]);
return 0;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- KEPServer配置
- Taishan Office Technology Lecture: scaling and opening files
- Symmetric encryption and asymmetric encryption
- Self optimization of wireless cell load balancing based on machine learning technology
- Error: image clipToBoundsAndScale, argument 'input'
- Internal and external troubles of digital collection NFT "boring ape" bayc
- 4 search insertion location
- Ten year structure five year life-07 young and vigorous transformation
- MIMO array 3D imaging technology based on mobile terminal
- SQL Server2000 database error
猜你喜欢

解决 ImportError: cannot import name 'abs' 导入tensorflow报错

BeautifulSoup的使用

黑白像素分布对迭代次数的影响

How to build a data index system is the most effective. It will take you a quick start from 0 to 1

Use of parsel

One stop monitoring of the software and hardware infrastructure of the whole university, and Suzhou University replaces PostgreSQL with time series database

Openatom openharmony sub forum, see you today at 14:00! Wonderful release of memorabilia attached

深析C语言的灵魂 -- 指针

Pyqt5 rapid development and practice 4.2 QWidget

Shortest moving distance and entropy of morphological complex
随机推荐
I've compromised. Since everyone wants to call me Yelin, there's nothing I can do
SQL Server2000 database error
熵与形态的非递进现象
迭代次数和熵之间关系的一个验证试验
SQL Server2000数据库错误
How to assemble a registry
Non progressive phenomena of entropy and morphology
Learning notes uni app
9 UAV array
洛谷P1441 砝码称重
tf.AUTO_ Function of reuse
Use of pyquery
Ansible
antd中table hover上去的背景色样式修改
基于FPGA的ECG信号采集,存储以及传输系统verilog实现
How to build a real-time development platform to deeply release the value of enterprise real-time data?
2022牛客多校训练(3)A-Ancestor 题目翻译
MIMO array 3D imaging technology based on mobile terminal
Integrated design of communication perception based on CSI: problems, challenges and Prospects
What is the issuing price of NFT (Interpretation of NFT and establishment of NFT world outlook)
