hdu3182---Hamburger Magi(状压dp)

【异常】Codybuddy Error Code: 14003 too many requests 限流报错问题排查与解决指南 14003报错本质为服务端限流拦截,并非账号封禁或程序致命故障,90%以上的场景可通过等待冷却+规范使用行为解决。通过本文的排查步骤,可快速恢复工具使用,同时规避后续重复触发该问题。 阅读详情

Problem Description
In the mysterious forest, there is a group of Magi. Most of them like to eat human beings, so they are called “The Ogre Magi”, but there is an special one whose favorite food is hamburger, having been jeered by the others as “The Hamburger Magi”.
Let’s give The Hamburger Magi a nickname “HamMagi”, HamMagi don’t only love to eat but also to make hamburgers, he makes N hamburgers, and he gives these each hamburger a value as Vi, and each will cost him Ei energy, (He can use in total M energy each day). In addition, some hamburgers can’t be made directly, for example, HamMagi can make a “Big Mac” only if “New Orleams roasted burger combo” and “Mexican twister combo” are all already made. Of course, he will only make each kind of hamburger once within a single day. Now he wants to know the maximal total value he can get after the whole day’s hard work, but he is too tired so this is your task now!

Input
The first line consists of an integer C(C<=50), indicating the number of test cases.
The first line of each case consists of two integers N,E(1<=N<=15,0<=E<=100) , indicating there are N kinds of hamburgers can be made and the initial energy he has.
The second line of each case contains N integers V1,V2…VN, (Vi<=1000)indicating the value of each kind of hamburger.
The third line of each case contains N integers E1,E2…EN, (Ei<=100)indicating the energy each kind of hamburger cost.
Then N lines follow, each line starts with an integer Qi, then Qi integers follow, indicating the hamburgers that making ith hamburger needs.

Output
For each line, output an integer indicating the maximum total value HamMagi can get.

Sample Input

1
4 90
243 464 307 298
79 58 0 72
3 2 3 4
2 1 4
1 1
0

Sample Output

298

Source
HDU 2009-10 Programming Contest

Recommend
lcy | We have carefully selected several similar problems for you: 3180 3176 3178 3179 3175

dp[i]表示做汉堡的状态为i时得到的最多的能量

/*************************************************************************
    > File Name: hdu3182.cpp
    > Author: ALex
    > Mail: zchao1995@gmail.com 
    > Created Time: 2015年04月28日 星期二 11时29分32秒
 ************************************************************************/

#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#include <set>
#include <vector>

using namespace std;

const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double eps = 1e-15;
typedef long long LL;
typedef pair <int, int> PLL;

int V[20], C[20];
int dp[(1 << 15) + 10];
int use[20];

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        int n, E;
        scanf("%d%d", &n, &E);
        memset(dp, -1, sizeof(dp));
        dp[0] = 0;
        memset(use, 0, sizeof(use));
        for (int i = 0; i < n; ++i) {
            scanf("%d", &V[i]);
        }
        for (int i = 0; i < n; ++i) {
            scanf("%d", &C[i]);
        }
        int m, tmp;
        for (int i = 0; i < n; ++i) {
            scanf("%d", &m);
            while (m--) {
                scanf("%d", &tmp);
                --tmp;
                use[i] |= (1 << tmp);
            };
        }
        for (int i = 0; i < (1 << n); ++i) {
            int cost = 0;
            for (int j = 0; j < n; ++j) {
                if (i & (1 << j)) {
                    cost += C[j];
                }
            }
            if (cost > E) {
                continue;
            }
            for (int j = 0; j < n; ++j) {
                if (!(i & (1 << j)) && dp[i] != -1) {
                    if ((use[j] & i) == use[j]) {
                        if (cost + C[j] <= E) {
                            dp[i | (1 << j)] = max(dp[i | (1 << j)], dp[i] + V[j]);;
                        }
                    }
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < (1 << n); ++i) {
            ans = max(ans, dp[i]);
        }
        printf("%d\n", ans);
    }
    return 0;
}
Jetson AGX Orin平台Jetpack5升级Jetpack6,自研载板USB不工作问题调试 1. 问题描述将AGX Orin工业的新板放到定制的载板上当在ubuntu 22和Jetpack 6.1上使用SDKManager刷机时,lsusb为空,并且在引导时没有发现/注册xusb设备。USB C端口正常打开并供电,但似乎没有数据传输。在Ubuntu 18 Jetpack 5.1.4 SDKManager上同样刷机之后,usb C集线器在引导时被正确地发现,显示在lsusb中,并识别/挂载外部驱动器。 阅读详情

相关推荐

Windows下RISC-V开发环境搭建:xpack-riscv-none-elf-gcc安装配置全攻略

本文详细介绍了在Windows平台下搭建RISC-V开发环境的完整流程,重点讲解xpack-riscv-none-elf-gcc工具链的安装配置方法。从环境变量设置到VSCode集成开发环境搭建,涵盖汇编程序和C程序开发实践,为开发者提供一站式解决方案,助力快速掌握RISC-V架构开发技能。

weixin_26765287的博客 437

HDU3182 - Hamburger Magi(状压DP)

题目链接 HDU3182 【题意】

转移到dawxy.com 685

数据科学常见模型总结(二)-倾向性得分匹配模型

PSM的核心思想是从未受干预的用户群体中,找到和干预对象一模一样的用户,这样就可以把因果效应归因到干预上。

wudelong0112的专栏 4889

HDU 3177 Crixalis's Equipment

http://acm.hdu.edu.cn/showproblem.php?pid=3177 Crixalis's Equipment Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 594Accepted Submi...

anjuepo2897的博客 169

避坑指南:Qgis等时圈分析中ORS插件Key申请与参数设置的常见错误

本文详细解析了QGIS等时圈分析中ORS插件从API密钥申请到参数优化的全流程避坑指南。针对密钥激活、出行模式选择、时空参数设置等七个高频故障点,提供了实用的调试方案和优化技巧,帮助用户高效完成空间可达性分析。

weixin_42546508的博客 300

以ATT&CK为例构建网络安全知识图

随着攻击工具、方法的逐渐升级和复杂化,安全数据的大规模融合,攻防对抗愈加激烈。安全团队如何在浩瀚数据中有效发现高级威胁的蛛丝马迹,如何把网络安全专家的经验、知识有效转化为可复制可扩展的数据分析能力,如何将对抗高级威胁的“炼金术”逐步升级为科学淘金指南,如何将安全从业者从繁重的体力劳动中解放出来,愈发成为安全能力亟需突破的难点和重点,也是我们正在探索的方向。正如医疗行业中治疗疑难杂症依赖医疗专家,网络空间高级威胁的防护和处置也依赖安全专家的经验与知识。

2401_88752684的博客 1090

Hamburger Magi(hdu 3182)

Hamburger Magi Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 437Accepted Submission(s): 144 Problem Description In the mysterious ...

weixin_30496431的博客 167

Unity之OpenXR+XR Interaction Toolkit实现 Gaze眼部追踪

在虚拟现实(VR)和增强现实(AR)应用中,眼动追踪是一项强大而受欢迎的技术。它可以让开发者更好地理解用户的注意力和行为,并创造出更加沉浸和智能的体验。在本文中,我们将探讨如何使用 Unity OpenXR 实现Gaze眼部追踪功能。

TxNet 1751

Hamburger Magi(hdu 3182)

Hamburger Magi Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Problem Description In the mysterious forest, there is a group of Magi. Most of them like to eat hum

残阳止水 411

Tableau学习教程(万字保姆级教程)​​​​​​

​Tableau学习教程(保姆级教材,学不会私信留言来找我) 从BI系统开发的角度来学习tableau工具,更学会报表开发的流程 内含学习使用数据源,tableau打包工作簿,可直接提取使用 ​...

小菜菜的博客 6万+

【DRAM存储器六十九】DDR5介绍--2N mode 和 CS Geardown mode

摘要: DDR5内存速率提升至8400MT/s以上时,信号完整性成为关键挑战。JEDEC在JESD79-5B标准中引入2N Mode和CS Geardown Mode两项技术,通过“时间换稳定性”优化时序裕量。2N Mode默认启用,将命令周期延长至两倍时钟周期,增强全局命令稳定性;CS Geardown Mode则针对片选信号(CS_n)降低采样频率,提升局部信号容错能力。两者均需通过特定寄存器配置,适用于高频场景下的性能与稳定性平衡。这些技术为DDR5在高频运行中提供了可靠的时序保障。

highman110的博客 219

HDU 3182 Hamburger Magi(状压DP解决有顺序背包问题)

Hamburger Magi Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description In the mysterious forest, there is a group of Magi. Most of them l

MR CODER 397

2026年GESP3月认证C++五级真题解析

因为要合并成升序数组,所以当A[i]小于等于B[j]时,取A[i],否则取B[j]。当a[i]>a[j]时,左边数组中从i到m的所有元素都大于a[j],因此逆序对数量增加m-i+1。给定一个包含n个互不相同的正整数的数组A与一个包含m个互不相同的正整数的数组B,请你帮忙计算有多少个数在数组A与数组B中均出现。下面代码实现两个整数除法,其中被除数为一个“大整数”,用字符串表示,除数是一个小整数,用int表示,则横线处应该填写()。且a[i] > a[j],则a[i]和a[j]是一个逆序对。

lan_in的博客 118

HDU 3182 Hamburger Magi(状压DP)

In the mysterious forest, there is a group of Magi. Most of them like to eat human beings, so they are called “The Ogre Magi”, but there is an special one whose favorite food is hamburger, having been

sulisulisu的博客 394

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU3182 Hamburger Magi【状压DP】

题目链接:Hamburger Magi 分析:每种汉堡只能做一次,恰好就是0~(1<<n)-1的所有状态; #include<bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const int maxn=(1<<15)+100; int dp[ma...

MaJorieL 187

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

hdu 3182 Hamburger Magi(状压dp)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=3182 预处理+dp #include #include #include using namespace std; const int N=15; int val[N],cost[1<<N],energy[N],last[N]; int dp[1<<N]; int n,m; void init() {

a709743744的博客 499

HDU 3182 Hamburger Magi(状压dp)

HDU 3182 Hamburger Magi(状压dp)

1718

【DP】 HDU 3182 Hamburger Magi 状压

汉堡间有先吃后吃的关系

Kewowlo 713

hdu_3182_Hamburger Magi(状压DP)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3182 题意:有n个汉堡,做每个汉堡需要消耗一定的能量,每个汉堡对应一定的价值,且只能做一次,并且做当前汉堡需要先做出列出的汉堡,求最大的价值 题解:状压DP #include #define FFC(i,a,b) for(int i=a;i<=b;++i) int T,n,all,end,no

bin_gege的博客 400

HDU - 3182:Hamburger Magi(状压DP)

Hamburger Magi                                                        Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)                                          

Mitsuha_的博客 577

HDU5823(状压DP)

给你一个n个点的图,问每个子集的最小色数 题解:每个子图的染色问题,可以看成是找每个子图的独立集问题(两两顶点互不相邻的图叫独立集),可以先枚举每个状态,然后枚举每个顶点,表示以这个顶点为起始的子图,再枚举每个顶点,表示这个顶点和上面那个顶点所构成的图是一个独立集,预处理出所有非法的状态,即他们之间有边。 首先预处理出每个点集的子集是否为独立集. 然后令dp[S]表示点集S的导出子图的

nucshiyilang的博客 465

HDU 3182 Hamburger Magi

题目:http://acm.hdu.edu.cn/showproblem.php?pid=3182 题意:有n个汉堡,每个汉堡有一个价值和做汉堡需要的体力,并且做有些汉堡前需要先做别的汉堡,问最多能做出多大价值 每个汉堡只能做一次并且有先后顺序,所以需要状压dp而不能直接暴力判断 做汉堡的前置关系可以用状压来简化判断 还可以预处理出每个状态需要花费的体力 #inclu...

dengyaodan0206的博客 160

HDU 3182 Hamburger Magi (状态压缩DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3182 #include&lt;bits/stdc++.h&gt; using namespace std; #define debug puts("YES"); #define rep(x,y,z) for(int (x)=(y);(x)&lt;(z);(x)++) #define read(x,...

满月照亮的路 275
上一篇: Codeforces Round #179 (Div. 2)---D. Greg and Graph(离线+floyd)
下一篇: Codeforces Round #227 (Div. 2)---E. George and Cards(贪心, 树状数组+set维护, 好题!)
tokers
博客等级 码龄12年 71粉丝 700原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值