当前位置:网站首页>Acdreamoj1110 (multiple backpacks)
Acdreamoj1110 (multiple backpacks)
2022-07-06 21:14:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
Serie A Champion : Multiple bare backpacks . The problem of water .
resolvent : Just like backpacks , Just add an array , Record the number of times each item has been used , When it's more than storage pass Not updated .
Another way is to compress each item in binary . The first code is relatively simple ;
Code :
/******************************************************
* author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <string.h>
//freopen ("in.txt" , "r" , stdin);
using namespace std;
#define eps 1e-8
#define zero(_) (abs(_)<=eps)
const double pi=acos(-1.0);
typedef long long LL;
const int Max=100010;
const int INF=1000000007;
int a[103];
int num[103];
int rem[Max];
bool ans[Max];
int n,cap;
int main()
{
int t;
//cout<<pow(6,4)-1<<endl;
scanf("%d",&t);int kk=1;
while(t--)
{
memset(ans,0,sizeof ans);
scanf("%d%d",&n,&cap);
for(int i=0; i<n; i++)
scanf("%d",a+i);
for(int i=0; i<n; i++)
scanf("%d",num+i);
ans[0]=1;
for(int i=0; i<n; i++)
{
memset(rem,0,sizeof rem);
for(int j=0; j<=cap; j++)
{
if(j+a[i]>cap||rem[j]>=num[i])
continue;
if(ans[j])
{
if(ans[j+a[i]])
{
rem[j+a[i]]=min(rem[j+a[i]],rem[j]+1);
continue;
}
ans[j+a[i]]=1;
rem[j+a[i]]=rem[j]+1;
}
}
}
int out=0;
for(int i=1; i<=cap; i++)
if(ans[i])
out++;
printf("Case %d: %d\n",kk++,out);
}
return 0;
}
/*
4 100000
1 12 456 5678
5 5 5 5
*/
Copyright notice : This article is the original article of the blogger , Blog , Do not reprint without permission .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117094.html Link to the original text :https://javaforall.cn
边栏推荐
- It's almost the new year, and my heart is lazy
- Mtcnn face detection
- 防火墙基础之外网服务器区部署和双机热备
- KDD 2022 | 通过知识增强的提示学习实现统一的对话式推荐
- Pycharm remote execution
- Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
- 968 edit distance
- js之遍历数组、字符串
- Thinking about agile development
- Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
猜你喜欢
Comprehensive evaluation and recommendation of the most comprehensive knowledge base management tools in the whole network: flowus, baklib, jiandaoyun, ones wiki, pingcode, seed, mebox, Yifang cloud,
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
##无yum源安装spug监控
3D人脸重建:从基础知识到识别/重建方法!
Opencv learning example code 3.2.3 image binarization
全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
2017 8th Blue Bridge Cup group a provincial tournament
爱可可AI前沿推介(7.6)
随机推荐
ICML 2022 | flowformer: task generic linear complexity transformer
【mysql】游标的基本使用
Performance test process and plan
Nodejs教程之让我们用 typescript 创建你的第一个 expressjs 应用程序
OSPF多区域配置
JS according to the Chinese Alphabet (province) or according to the English alphabet - Za sort &az sort
2022 fields Award Announced! The first Korean Xu Long'er was on the list, and four post-80s women won the prize. Ukrainian female mathematicians became the only two women to win the prize in history
防火墙基础之外网服务器区部署和双机热备
Why do job hopping take more than promotion?
Manifest of SAP ui5 framework json
The biggest pain point of traffic management - the resource utilization rate cannot go up
R语言可视化两个以上的分类(类别)变量之间的关系、使用vcd包中的Mosaic函数创建马赛克图( Mosaic plots)、分别可视化两个、三个、四个分类变量的关系的马赛克图
请问sql group by 语句问题
How to implement common frameworks
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
OneNote in-depth evaluation: using resources, plug-ins, templates
爱可可AI前沿推介(7.6)
【论文解读】用于白内障分级/分类的机器学习技术
966 minimum path sum
ACdreamoj1110(多重背包)