当前位置:网站首页>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
边栏推荐
- Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
- Laravel notes - add the function of locking accounts after 5 login failures in user-defined login (improve system security)
- 华为设备命令
- KDD 2022 | realize unified conversational recommendation through knowledge enhanced prompt learning
- What's the best way to get TFS to output each project to its own directory?
- 如何实现常见框架
- Performance test process and plan
- Word bag model and TF-IDF
- 什么是RDB和AOF
- Nodejs教程之让我们用 typescript 创建你的第一个 expressjs 应用程序
猜你喜欢
SAP UI5 框架的 manifest.json
3D人脸重建:从基础知识到识别/重建方法!
Opencv learning example code 3.2.3 image binarization
PHP saves session data to MySQL database
Aike AI frontier promotion (7.6)
Swagger UI教程 API 文档神器
2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
15 millions d'employés sont faciles à gérer et la base de données native du cloud gaussdb rend le Bureau des RH plus efficace
性能测试过程和计划
Aiko ai Frontier promotion (7.6)
随机推荐
Reinforcement learning - learning notes 5 | alphago
拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
js之遍历数组、字符串
Infrared thermometer based on STM32 single chip microcomputer (with face detection)
el-table表格——sortable排序 & 出现小数、%时排序错乱
Thinking about agile development
@GetMapping、@PostMapping 和 @RequestMapping详细区别附实战代码(全)
Laravel notes - add the function of locking accounts after 5 login failures in user-defined login (improve system security)
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
Introduction to the use of SAP Fiori application index tool and SAP Fiori tools
Redis insert data garbled solution
Word bag model and TF-IDF
R语言可视化两个以上的分类(类别)变量之间的关系、使用vcd包中的Mosaic函数创建马赛克图( Mosaic plots)、分别可视化两个、三个、四个分类变量的关系的马赛克图
967- letter combination of telephone number
js中,字符串和数组互转(二)——数组转为字符串的方法
审稿人dis整个研究方向已经不仅仅是在审我的稿子了怎么办?
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
每个程序员必须掌握的常用英语词汇(建议收藏)
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?