问题 I: Spell Boost

时间限制: 1 Sec  内存限制: 128 MB
提交: 63  解决: 8
[提交] [状态] [讨论版] [命题人:admin]

题目描述

Shadowverse is a funny card game. One day you are playing a round of this game.
You have n cards, each with two attributes wi and xi. If you use card i, you will cost wi points of power and cause xi damage to the enemy.
Among them, there are two special types of cards: some cards are magic cards and some have “spell boost effect”. Everytime you have used a magic card, for each unused “spell boost effect” card i: if the the current cost of i (i.e. wi) is positive, then wi will be reduced by 1. Note that some cards may be both magic cards and have spell boost effect.
Now you have W points of power, you need to calculate maximum total damage you can cause.

输入

Input is given from Standard Input in the following format:
n W
w1 x1 is_magic1 is_spell_boost1
w2 x2 is_magic2 is_spell_boost2
.
.
wn xn is_magicn is_spell_boostn
Constraints
1 ≤ n ≤ 500
0 ≤ W, wi, xi ≤ 500, and all of them are integers.
is_magici means: If this card is magic card, the value is 1, otherwise the value is 0.
is_spell_boosti means: If this card has spell boost effect, the value is 1, otherwise 0

输出

One integer representing the maximum total damage.

样例输入

3 3
3 3 1 1
2 3 1 1
1 3 1 1

样例输出

9

题目大意是说给你一些费用,你有一些卡片,具有魔法或者攻击或者两者兼而有之的属性,每使用一张卡片都需要不同的费用,你每使用一张魔法卡,所有没使用过的具有攻击属性的卡片的费用都会减一,每使用一张具有攻击属性的卡,就能造成一定量的伤害,求最大伤害。

解法:i枚举现在用到第几张卡片,j为费用,k为已经打出了几张具有魔法属性的卡,用个滚动数组记录当前状态所能造成的最大伤害值即可。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 505;
int dp[505][505][2];
struct fun
{int a,b,flag1,flag2;int flag;
}z[maxn];
int cnt;
bool cmp(fun a, fun b)
{if (a.flag == 2 && b.flag == 2)return a.a > b.a;return a.flag > b.flag;
}
int main()
{
//    freopen("in.txt", "r", stdin);int n,w;scanf("%d%d", &n, &w);for (int i = 0; i < n; ++i){scanf("%d%d%d%d", &z[i].a, &z[i].b, &z[i].flag1, &z[i].flag2);if (z[i].flag1)cnt++;if (z[i].flag1){if (z[i].flag2)z[i].flag = 2;elsez[i].flag = 1;}else{if (z[i].flag2)z[i].flag = 3;elsez[i].flag = 0;}}sort(z, z + n, cmp);int pre,now;pre = 1;now = 0;for(int i = 0; i < n; i++){now ^= 1;pre ^= 1;for(int j = 0; j <= w; j++)for(int k = 0; k <= cnt; k++){int tmp = z[i].a;int tmpk = k + z[i].flag1;if(z[i].flag2)tmp = max(tmp - k, 0);dp[j][k][now] = dp[j][k][pre];if(tmp <= j && tmpk <= cnt)dp[j][k][now] = max(dp[j][k][now], dp[j - tmp][tmpk][pre] + z[i].b);}}printf("%d\n", dp[w][0][now]);return 0;
}

东北四省赛 Spell Boost相关推荐

  1. 2018东北四省赛 Store The Matrix (矩阵)

    2018东北四省赛 Store The Matrix (矩阵) 题目描述 Given a matrix M with r rows and c columns. It is obviously tha ...

  2. 2018东北四省赛 Spin A Web 曼哈顿距离最小生成树

    莫队的论文,讲的很清晰 问题描述:给定平面N个点,两边相连的代价为曼哈顿距离,求这些点的最小生成树 按一般想法,prime复杂度O(n^2),Kruskal复杂度O(n^2 logn),N很大时,这复 ...

  3. 东北四省赛H-Skyscraper-线段树的区间合并优化

    题目描述: At the main street of Byteland, there will be built n skyscrapers, standing sequentially one n ...

  4. 2021CCPC东北四省赛 D. Lowbit 势能线段树

    传送门 分析 分析一下x+lowbit(x)x + lowbit(x)x+lowbit(x)这个操作 如果多次操作之后,那么xxx中只会有最高位存在一,这个时候再执行一次操作就会使整个数字乘二 所以, ...

  5. Spell Boost

    题目描述 Shadowverse is a funny card game. One day you are playing a round of this game. You have n card ...

  6. 【随笔】2015年ICPC四省赛/邀请赛小结

    因为槽点太多了,所以周日比完赛,周一就开始写文章吐槽了QAQ 这比赛真坑,真坑,真坑啊!!!(重要的事情要说三遍) 本次比赛是ICPC主办的东北赛,哈工大跟吉大可能是因为有了CCPC所以不来参加了吧, ...

  7. 和平精英明星四排赛,你的网游.fans域名抢了没?

    <和平精英>可谓是当下游戏界的霸王了~随着越来越多的人在玩,"一起吃鸡"也成了这款游戏的代言词.就在上周日,<和平精英>的特种兵代言人"迪丽热巴. ...

  8. 东北酱油 模拟赛 期望dp

    自动取款机 [问题描述] 小沈阳在小品里说过:"人生最痛苦的事情是人死了,钱还没花了". 于是小宋(80岁)决定要将所有的储蓄从ATM机中取出花光. 小宋忘记了她有多少存款(银行卡 ...

  9. 2022 ciscn 东北赛区分区赛 部分 wp

    WEB: eztp1 给源码了 thinkphp3.2.3,index路由有个 textBox方法,简单的设置参数和渲染, 3.2.3 有个文件包含,关键点就是File.class.php 里的变量覆 ...

  10. 第十五届东北四省大学生程序设计大赛J. Transform(计算几何,罗德里格斯旋转公式)

    题目链接:Problem - J - Codeforces 题意: 给出两个点求第二个点绕从原点到第一个点这条轴旋转 r或 − r 得到两个点,输出 z  坐标更大的那个点: 首先普及一下罗德里格斯旋 ...

最新文章

  1. 洛谷1941飞扬的小鸟
  2. Kafka配置消息保存时间的方法
  3. 新课改实践下美术课程的新教学观
  4. 容器技术之快速了解K8S各抽象资源及组件架构
  5. Spring mvc @SessionAttribute
  6. Python抖音机器人制作!让你有看不完的小姐姐
  7. solidity 合约权限授权_Curve + zkSync L2:以太坊的ZK Rollup智能合约
  8. Linux下载Mysql
  9. m2 ngff无线网卡接口的笔记本电脑加装苹果网卡,完美安装苹果mac OS
  10. CAD .Net 开发-快速入门
  11. 计算机对口升学的专科学校,2014对口升学计算机各地专科大学
  12. 宝塔linux_开源、强大的Linux服务器集群管理工具,比宝塔好用!
  13. 小公司一个人如何进行测试
  14. tomcat springmvc 图片404不显示
  15. FSL 功能磁共振影像分析: single-session
  16. 【Python 基础教程】一文理清Python函数的细枝末节
  17. KDB内核调试 - 1
  18. 接触 Firebug
  19. 怎样在bios屏蔽集成显卡
  20. A/D转换器和D/A转换器

热门文章

  1. APICloud框架——获取本地图片信息
  2. C语言 递归实现指数函数
  3. php 手机号码所属城市,基于PHP的手机号码归属地查询
  4. mysql的strict_linux关闭mysql strict mode的方法介绍
  5. 智商决定能力和情商决定本事的分析
  6. 路由器组成及路由器发展概述
  7. 国美易卡对IP层数据进行处理,国美易卡对TCP/IP的封装
  8. java idle 机制_Flink中Idle停滞流机制(源码分析)
  9. 计算机考试怎样切换输入法,高级会计师考场如何切换输入法?
  10. Spring Boot之自定义JSON转换器