当前位置:网站首页>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
边栏推荐
- 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,
- ACdreamoj1110(多重背包)
- 20220211 failure - maximum amount of data supported by mongodb
- SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
- 全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
- 【mysql】游标的基本使用
- What is the difference between procedural SQL and C language in defining variables
- Le langage r visualise les relations entre plus de deux variables de classification (catégories), crée des plots Mosaiques en utilisant la fonction Mosaic dans le paquet VCD, et visualise les relation
- No Yum source to install SPuG monitoring
- ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
猜你喜欢
OneNote 深度评测:使用资源、插件、模版
3D人脸重建:从基础知识到识别/重建方法!
【mysql】触发器
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
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
This year, Jianzhi Tencent
基于STM32单片机设计的红外测温仪(带人脸检测)
[200 opencv routines] 220 Mosaic the image
ICML 2022 | flowformer: task generic linear complexity transformer
[sliding window] group B of the 9th Landbridge cup provincial tournament: log statistics
随机推荐
Aiko ai Frontier promotion (7.6)
Nodejs tutorial expressjs article quick start
防火墙基础之外网服务器区部署和双机热备
如何实现常见框架
966 minimum path sum
@PathVariable
Performance test process and plan
##无yum源安装spug监控
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
c#使用oracle存储过程获取结果集实例
ICML 2022 | flowformer: task generic linear complexity transformer
How do I remove duplicates from the list- How to remove duplicates from a list?
Thinking about agile development
Vim 基本配置和经常使用的命令
El table table - sortable sorting & disordered sorting when decimal and% appear
Reference frame generation based on deep learning
请问sql group by 语句问题
每个程序员必须掌握的常用英语词汇(建议收藏)
【论文解读】用于白内障分级/分类的机器学习技术
PG基础篇--逻辑结构管理(事务)