当前位置:网站首页>Hybrid Backpack
Hybrid Backpack
2022-04-22 16:58:00 【2020100XWH】
1. Scrolling array dp Space optimization
2. Discuss the direct classification of different backpacks
01: Enumerate in reverse order
Completely : Positive order enumeration
Multiple backpack : Binary grouping
3.!. Pay attention to input, do not use self addition Write separately !
#include<bits/stdc++.h>
using namespace std;
int t1,m1,t2,m2;
int dp[100006];
int w[2000005],st[2000006],cc[2000006];
int main()
{
scanf("%d:%d %d:%d",&t1,&m1,&t2,&m2);
int tt=(t2-t1)*60+m2-m1;
int n;
cin>>n;
int cnt=0;
for(int i=1;i<=n;++i)
{
++cnt;
scanf("%d%d%d",&st[cnt],&w[cnt],&cc[cnt]);
if(cc[cnt]>1)
{
int c=1;
int k=cc[cnt];
int stt=st[cnt];
int ww=w[cnt];
while(k-c>0)
{
if(stt*c>tt)
break;
k-=c;
st[cnt]=stt*c;
cc[cnt]=1;
w[cnt++]=ww*c;
c*=2;
}
if(k>0&&stt*k<=tt)
{
w[cnt]=ww*k;
cc[cnt]=1;
st[cnt++]=stt*k;
}
cnt--;
}
}
for(int i=1;i<=cnt;++i)
{
if(cc[i]==1)
{
for(int j=tt;j>=st[i];--j)
{
dp[j]=max(dp[j],dp[j-st[i]]+w[i]);
}
}
if(cc[i]==0)
{
for(int j=st[i];j<=tt;++j)
{
dp[j]=max(dp[j],dp[j-st[i]]+w[i]);
}
}
}
// for(int i=1;i<=cnt;++i)
// {
// cout<<st[i]<<" "<<w[i]<<" "<<cc[i]<<endl;
// }
// cout<<cnt<<endl;
cout<<dp[tt];
return 0;
}
版权声明
本文为[2020100XWH]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221652566699.html
边栏推荐
- SDN学习之Opendaylight浅析(四)
- [distributed project] certification service center, social login oauth2 0. Single sign on and distributed session solutions
- MySQL_ 00_ Get to know MySQL
- 小熊电器的三重压力:扩张、存货和对手
- Network public opinion monitoring system
- 华为走在老路上
- 7 capabilities of data analysis: sorting out data needs
- 认知系列4: 《认知突围》笔记
- 4亿女性刚需,各路资本杀伐:藏在卫生巾里的1000亿生意
- CrashSight 常规功能&特色功能介绍
猜你喜欢

Vscode plug-in package migration and specified location

小熊电器的三重压力:扩张、存货和对手

Cvpr2019 domain adaptation / semantic segmentation: adapting structural information across domains for boosting SEMA

JD side: how can a child thread get the value of the parent thread ThreadLocal? I got...

Shiro缓存管理

20220420 reasoning framework analyzes what is gradient

SDN学习之Opendaylight浅析(五)

CrashSight 常规功能&特色功能介绍

MySQL_00_初识MySQL

【面试普通人VS高手系列】请说一下网络四元组
随机推荐
[Dahua cloud native] wonderful relationship between message queue and express cabinet (with video)
恢复wifi操作
VSCode插件打包迁移与指定位置
SDN学习之Opendaylight浅析(二)
leetcode:23. 合并K个升序链表
JD side: how can a child thread get the value of the parent thread ThreadLocal? I got...
DevExpress WPF入门指南 - 运行时生成的POCO视图模型(一)
正则匹配URL
[filtering and convolution (II)]
数据安全审计OTP配置
多线程使用redis进行累加结果不对解决方案
The [ANSYS Workbench] mechanical interface displays the model tree window and the details window
面向全球市场,PlatoFarm今日登录HUOBI等全球四大平台
知乎香港上市,首家以双重主要上市回港的中概股
AQS源码阅读
数据分析7大能力:梳理数据需求
Update description of the latest process engine flowable 6.7.2
FRP reverse proxy
SDN学习之Opendaylight浅析(五)
20220420 推理框架解析 什么是梯度