Spell Boost

题目描述

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

 

来源/分类

2018东北四省赛 

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define lowbit(x)  x&(-x)
typedef pair<int,int>pa;
const int maxn=505;
int dp[2][maxn][maxn];
int n,w;
struct node
{
    int w,x,ma,bo;
}ss[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",&ss[i].w,&ss[i].x,&ss[i].ma,&ss[i].bo);
    }
    sort(ss+1,ss+1+n,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+ss[i].ma;
                int ww=k+max(0,ss[i].w-j*ss[i].bo);
                if(ww<=w)
                {
                    dp[i%2][jj][ww]=max(dp[i%2][jj][ww],dp[(i-1)%2][j][k]+ss[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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值