7233: Spell Boost

时间限制: 1 Sec  内存限制: 128 MB
提交: 68  解决: 11
[提交] [状态] [讨论版] [命题人: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

题意:给n张牌,总体力w,每张牌需要花费wi造成xi的伤害,同时每张牌可能会有两个属性,第一个属性可以在使用时使所有具

有第二种属性的牌的w减1,计算最大伤害

思路:DP,似乎每次看之前都觉得很难,看懂了又觉得挺简单,都没啥可讲的,太菜了

代码:

#include <bits/stdc++.h>using namespace std;const int maxn = 505;
int n, w;
int dp[2][maxn][maxn];
struct node {int w, x, ma, bo;
} s[maxn];bool cmp(node a, node b) {if (a.ma != b.ma) return a.ma > b.ma;if (a.bo != b.bo) return a.bo < b.bo;return a.w < b.w;
}int main() {scanf("%d%d", &n, &w);for (int i = 1; i <= n; i++) {scanf("%d%d%d%d", &s[i].w, &s[i].x, &s[i].ma, &s[i].bo);}sort(s+1, s + n+1, cmp);memset(dp[0], -1, sizeof(dp[0]));dp[0][0][0] = 0;for (int i = 1; i <= n; i++) {memset(dp[i % 2], -1, sizeof(dp[i % 2]));for (int j = 0; j <= i; j++) {for (int k = 0; k <= w; k++) {if (dp[(i - 1) % 2][j][k] == -1) continue;dp[i % 2][j][k] = max(dp[i % 2][j][k], dp[(i - 1) % 2][j][k]);int jj = j + s[i].ma;int ww = k + max(0, s[i].w - j * s[i].bo);if (ww <= w)dp[i % 2][jj][ww] = max(dp[i % 2][jj][ww], dp[(i - 1) % 2][j][k] + s[i].x);}}}int ans = 0;for (int i = 0; i <= n; i++) {for (int j = 0; j <= w; j++) {ans = max(ans, dp[n % 2][i][j]);}}printf("%d\n", ans);return 0;
}

2018东北四省赛 Spell Boost DP相关推荐

  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. 2018冬令营模拟测试赛(九)

    2018冬令营模拟测试赛(九) [Problem A]王子 试题描述 不是所有王子都会遇见自己的中关村,主公,公主. 从前有个王子姓王,王王子遇到了一位美丽的公主,她的名字当然是公公主啦. 王王子对公 ...

  7. 2018 东北地区大学生程序设计竞赛(ABEHIK)

    HDU6500:Problem A. Game with string 题意: 给你一个字符串s以及它的m个子串的首尾位置,现在Alice和 Bob两个人轮流在任一子串的前面或者后面加1个字符,要求加 ...

  8. 2018冬令营模拟测试赛(十八)

    2018冬令营模拟测试赛(十八) [Problem A]Table 试题描述 输入 见"试题描述" 输出 见"试题描述" 输入示例 见"试题描述&qu ...

  9. 2018冬令营模拟测试赛(一)

    2018冬令营模拟测试赛(一) [Problem A]全面战争不可避 试题描述 补充说明:铁路毁坏指的是这条铁路彻底消失了,不会对之后的询问造成影响(即询问之间是独立的) 输入 输出 输入示例1 5 ...

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

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

最新文章

  1. IIS8 添加配置 WCF服务
  2. 深度并非一切:普林斯顿、英特尔提出ParNet,速度和准确性显著优于ResNet
  3. Spring Boot——易班优课YOOC课群在线测试自动答题解决方案(六)后端改造
  4. 万用socket神器Linux Netcat 命令
  5. mongodb副本集搭建
  6. webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc «(», expected punc
  7. Linux之pwd命令
  8. 物资管理系统c语言运行程序,C语言实现仓库物资管理系统.pdf
  9. 英康手机订单系统APP使用说明
  10. 【定时任务|开机启动】Windows Server 2008/2012 计划任务配置(任务计划程序)每分钟执行BAT...
  11. tomcat下载安装步骤(超详细)
  12. CubeMX配置SPI-Flash(W25Q256)
  13. 昆仑通态触摸屏如何把参数由触摸屏传递到PLC_西门子PLC与触摸屏、变频器的恒压供水分享...
  14. 可控硅工作原理及参数详解
  15. H3CNE题库(带答案版)
  16. linux 修改文件的权限
  17. 华中科技大学计算机学院本科生宿舍,[业余派]告诉你一个真正的华中科技大学...
  18. #379 – 将ToolTip当做放大器使用(Using a Tooltip As a Magnifier)
  19. 永久免费!吴恩达刚公布的深度学习课程上线网易云课堂
  20. 设某种二叉树有如下特点:每个结点要么是叶子结点,要么有2棵子树。假如一棵这样的二叉树中有m(m0)个叶子结点,那么该二叉树上的结点总数为( )。

热门文章

  1. tar命令下的--exclude
  2. P5144 【蜈蚣】
  3. bgp高防-服务器单线、双线、三线、BGP线路哪个更好?
  4. mysql的strict,MySQL Strict Mode关闭
  5. APM_Rover运行纲领分析,以pixhawk-fmuv2为硬件平台,ChibiOS为底层操作系统:
  6. java for 下标_java中foreach语句如何获取数组下标
  7. IPSEC over GRE
  8. 通过css布局实现去掉window.print()打印界面的页眉页脚
  9. 优思学院|什么是六西格玛(6sigma)?六西格玛概念解释
  10. python 利用matplolib给绘制的地图添加方框,将所需的区域圈出来