Two Types of Spells【模拟】

题目链接


  有两种魔法,一种是单纯的伤害为d(0 d),另一种是伤害为d,但是下一次伤害暴击(*2)为(1 d),现在,我们要用已有的魔法来进行组合,使得伤害总值最大。

  那么,很显然的,我们尽可能让值大的去进行“暴击化”处理,于是有如果这个值更大,我们就把这个值放进去暴击堆内去,这样的做法。

  然后,很多细节吧,调了蛮久的。

11
1 1
1 -1
1 2
0 3
0 -3
1 4
1 -4
1 5
0 6
1 -2
1 -5
36
0 136177412
0 -136177412
0 455326434
1 14442996
0 -455326434
0 958682748
1 104290903
0 -958682748
1 -14442996
1 -104290903
1 393108768
1 969925414
1 -393108768
1 -969925414
0 79968028
1 799927246
1 618210305
0 -79968028
1 -799927246
1 116180540
1 -116180540
1 -618210305
0 255573897
0 -255573897
0 295690421
0 -295690421
0 126320824
0 480081046
0 164983131
0 -480081046
1 402044589
0 -164983131
0 449987533
0 -449987533
1 927277221
1 -402044589
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <limits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#define lowbit(x) ( x&(-x) )
#define pi 3.141592653589793
#define e 2.718281828459045
#define INF 0x3f3f3f3f
#define HalF (l + r)>>1
#define lsn rt<<1
#define rsn rt<<1|1
#define Lson lsn, l, mid
#define Rson rsn, mid+1, r
#define QL Lson, ql, qr
#define QR Rson, ql, qr
#define myself rt, l, r
using namespace std;
typedef unsigned long long ull;
typedef unsigned int uit;
typedef long long ll;
int N, can_push_in;
set<int> inque, no_inque[2], minn[2];
map<int, bool> is_it_in, spells;
/* 1 times or 2 times */
void Push_in_1(int x)
{
    no_inque[spells[x]].insert(x);
    is_it_in[x] = false;
}
void Pop_out_1(int x)
{
    no_inque[spells[x]].erase(x);
}
void Push_in_2(int x)
{
    inque.insert(x);
    is_it_in[x] = true;
    minn[spells[x]].insert(x);
}
void Pop_out_2(int x)
{
    inque.erase(x);
    is_it_in[x] = false;
    minn[spells[x]].erase(x);
}
/*max or min value*/
int Min_Inque()
{
    if(inque.empty()) return 0;
    return *inque.begin();
}
int Min_In_0()
{
    if(minn[0].empty()) return 0;
    return *minn[0].begin();
}
int Min_In_1()
{
    if(minn[1].empty()) return 0;
    return *minn[1].begin();
}
int Max_not_in_0()
{
    if(no_inque[0].empty()) return 0;
    return *no_inque[0].rbegin();
}
int Max_not_in_1()
{
    if(no_inque[1].empty()) return 0;
    return *no_inque[1].rbegin();
}
/*end*/
int main()
{
    scanf("%d", &N);
    can_push_in = 0;
    ll ans = 0;
    for(int i=1, op, d, x, y, tmp, p; i<=N; i++)
    {
        scanf("%d%d", &op, &d);
        switch (op)
        {
            case 0:
            {
                if(d > 0)
                {
                    spells[d] = false;
                    if(can_push_in > inque.size())
                    {
                        Push_in_2(d);
                        ans += 2 * d;
                    }
                    else
                    {
                        x = Min_Inque();
                        if(x && d > x)
                        {
                            Pop_out_2(x);
                            Push_in_1(x);
                            ans -= x;
                            Push_in_2(d);
                            ans += 2 * d;
                        }
                        else
                        {
                            Push_in_1(d);
                            ans += d;
                        }
                    }
                }
                else
                {
                    d = -d;
                    if(is_it_in[d])
                    {
                        Pop_out_2(d);
                        ans -= 2 * d;
                        x = Max_not_in_0();
                        y = Max_not_in_1();
                        tmp = max(x, y);
                        if(minn[1].size() == can_push_in - 1)
                        {
                            if(x)
                            {
                                Push_in_2(x);
                                Pop_out_1(x);
                                ans += x;
                            }
                        }
                        else
                        {
                            if(tmp)
                            {
                                Push_in_2(tmp);
                                Pop_out_1(tmp);
                                ans += tmp;
                            }
                        }
                    }
                    else
                    {
                        Pop_out_1(d);
                        ans -= d;
                    }
                }
                break;
            }
            default:
            {
                if(d > 0)
                {
                    spells[d] = true;
                    p = Max_not_in_1();
                    if(d < p)
                    {
                        ans += d;
                        Push_in_1(d);
                        Pop_out_1(p);
                        ans -= p;
                        d = p;
                    }
                    if(can_push_in == inque.size() + 1)
                    {
                        Push_in_2(d);
                        ans += 2 * d;
                    }
                    else
                    {
                        x = Max_not_in_0();
                        y = Max_not_in_1();
                        tmp = max(x, y);
                        if(can_push_in)
                        {
                            if(d > tmp)
                            {
                                Push_in_2(d);
                                ans += 2 * d;
                            }
                            else
                            {
                                Pop_out_1(tmp);
                                Push_in_2(tmp);
                                Push_in_1(d);
                                ans += d;
                                ans += tmp;
                            }
                        }
                        else
                        {
                            Push_in_1(d);
                            ans += d;
                            x = Max_not_in_0();
                            if(x)
                            {
                                Pop_out_1(x);
                                Push_in_2(x);
                                ans += x;
                            }
                        }
                    }
                    can_push_in++;
                }
                else
                {
                    d = -d;
                    can_push_in--;
                    if(is_it_in[d])
                    {
                        Pop_out_2(d);
                        ans -= 2 * d;
                    }
                    else
                    {
                        Pop_out_1(d);
                        ans -= d;
                        x = Min_In_0();
                        y = Min_In_1();
                        tmp = x && y ? min(x, y) : x ^ y;
                        if(minn[1].size() == can_push_in)
                        {
                            if(y)
                            {
                                Pop_out_2(y);
                                Push_in_1(y);
                                ans -= y;
                            }
                            else
                            {
                                if(x)
                                {
                                    Pop_out_2(x);
                                    Push_in_1(x);
                                    ans -= x;
                                }
                            }
                        }
                        else
                        {
                            Pop_out_2(tmp);
                            Push_in_1(tmp);
                            ans -= tmp;
                        }
                    }
                }
                break;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
function Trig_blizzard_intelligence________2_Func002002003001 takes nothing returns boolean return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false ) endfunction function Trig_blizzard_intelligence________2_Func002002003002001 takes nothing returns boolean return ( IsUnitAliveBJ(GetFilterUnit()) == true ) endfunction function Trig_blizzard_intelligence________2_Func002002003002002 takes nothing returns boolean return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_blizzard_hero)) == true ) endfunction function Trig_blizzard_intelligence________2_Func002002003002 takes nothing returns boolean return GetBooleanAnd( Trig_blizzard_intelligence________2_Func002002003002001(), Trig_blizzard_intelligence________2_Func002002003002002() ) endfunction function Trig_blizzard_intelligence________2_Func002002003 takes nothing returns boolean return GetBooleanAnd( Trig_blizzard_intelligence________2_Func002002003001(), Trig_blizzard_intelligence________2_Func002002003002() ) endfunction function Trig_blizzard_intelligence________2_Func003A takes nothing returns nothing call AddSpecialEffectTargetUnitBJ( "overhead", GetEnumUnit(), "Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl" ) call CreateNUnitsAtLoc( 1, 'e000', GetOwningPlayer(udg_blizzard_hero), udg_blizzard_p, bj_UNIT_FACING ) call UnitDamageTargetBJ( bj_lastCreatedUnit, GetEnumUnit(), ( I2R(GetHeroInt(udg_blizzard_hero, true)) * 0.65 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD ) endfunction function Trig_blizzard_intelligence________2_Actions takes nothing returns nothing call YDWELocalVariableInitiliation( ) call YDWESetLocalVariableGroup( "g", GetUnitsInRangeOfLocMatching(BlzGetAbilityRealLevelField(BlzGetUnitAbility(udg_blizzard_hero, 'AHMB'), ABILITY_RLF_AREA_OF_EFFECT, GetUnitAbilityLevelSwapped('AHMB', udg_blizzard_hero)), udg_blizzard_p, Condition(function Trig_blizzard_intelligence________2_Func002002003)) ) call ForGroup( YDWEGetLocalVariableGroup("g"), function Trig_blizzard_intelligence________2_Func003A ) call GroupClear( YDWEGetLocalVariableGroup("g") ) call DestroyGroup( YDWEGetLocalVariableGroup("g") ) call YDWELocalVariableEnd( ) endfunction //=========================================================================== function InitTrig_blizzard_intelligence________2 takes nothing returns nothing set gg_trg_blizzard_intelligence________2 = CreateTrigger( ) call TriggerRegisterTimerExpireEventBJ( gg_trg_blizzard_intelligence________2, udg_blizzard_inte ) call TriggerAddAction( gg_trg_blizzard_intelligence________2, function Trig_blizzard_intelligence________2_Actions ) endfunction这段代码
02-07
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Wuliwuliii

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值