当前位置:网站首页>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
边栏推荐
- Thinking about agile development
- 愛可可AI前沿推介(7.6)
- Deployment of external server area and dual machine hot standby of firewall Foundation
- js中,字符串和数组互转(一)——字符串转为数组的方法
- Variable star --- article module (1)
- 全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
- This year, Jianzhi Tencent
- js 根据汉字首字母排序(省份排序) 或 根据英文首字母排序——za排序 & az排序
- Word bag model and TF-IDF
- 硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
猜你喜欢

硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件

【Redis设计与实现】第一部分 :Redis数据结构和对象 总结
![[interpretation of the paper] machine learning technology for Cataract Classification / classification](/img/0c/b76e59f092c1b534736132faa76de5.png)
[interpretation of the paper] machine learning technology for Cataract Classification / classification

1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效

Aiko ai Frontier promotion (7.6)

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,

SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍

3D人脸重建:从基础知识到识别/重建方法!

爱可可AI前沿推介(7.6)

2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
随机推荐
Is it profitable to host an Olympic Games?
监控界的最强王者,没有之一!
Web开发小妙招:巧用ThreadLocal规避层层传值
R language visualizes the relationship between more than two classification (category) variables, uses mosaic function in VCD package to create mosaic plots, and visualizes the relationship between tw
Data Lake (VIII): Iceberg data storage format
Web开发小妙招:巧用ThreadLocal规避层层传值
What's the best way to get TFS to output each project to its own directory?
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
Simple continuous viewing PTA
In JS, string and array are converted to each other (I) -- the method of converting string into array
华为设备命令
Opencv learning example code 3.2.3 image binarization
【深度学习】PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
每个程序员必须掌握的常用英语词汇(建议收藏)
@Detailed differences among getmapping, @postmapping and @requestmapping, with actual combat code (all)
[asp.net core] set the format of Web API response data -- formatfilter feature
Variable star --- article module (1)
启动嵌入式间:资源有限的系统启动
OAI 5g nr+usrp b210 installation and construction
Math symbols in lists