zoukankan      html  css  js  c++  java
  • Codeforces 976E

    题意略。

    思路:

    容易知道那a次倍增放在同一个怪身上是最优的,其余的怪我们只需要取hp值和damage值中间最大的那个就好了(在b值的限制下)。

    然而我们并不知道把那a次倍增放在哪个怪身上最好,那么我们就只能一只一只地试。

    #include<bits/stdc++.h>
    #define maxn 200005
    using namespace std;
    typedef long long LL;
    
    struct node{
        LL hp,dmg;
        node(LL a = 0,LL b = 0){
            hp = a,dmg = b;
        }
    };
    
    LL pwr2[30];
    node store[maxn];
    int n,a,b;
    
    bool cmp(const node& nd1,const node& nd2){
        return (nd1.hp - nd1.dmg) > (nd2.hp - nd2.dmg);
    }
    
    int main(){
        scanf("%d%d%d",&n,&a,&b);
        for(int i = 0;i < n;++i) scanf("%lld%lld",&store[i].hp,&store[i].dmg);
        sort(store,store + n,cmp);
        LL sum = 0;
        for(int i = 0;i < n;++i){
            if(i < b) sum += max(store[i].dmg,store[i].hp);
            else sum += store[i].dmg;
        }
        LL ans = sum;
        for(int i = 0;i < b;++i){
            LL tmp = sum;
            tmp -= max(store[i].dmg,store[i].hp);
            tmp += max(store[i].hp<<a,store[i].dmg);
            ans = max(ans,tmp);
        }
        if(b > 0){
            sum -= max(store[b - 1].dmg,store[b - 1].hp);
            sum += store[b - 1].dmg;
            for(int i = b;i < n;++i){
                LL tmp = sum;
                tmp -= store[i].dmg;
                tmp += max(store[i].hp<<a,store[i].dmg);
                ans = max(ans,tmp);
            }
        }
        printf("%lld
    ",ans);
        return 0;
    }
  • 相关阅读:
    Creative Cloud 无法连接问题
    HTTP_PROXY
    <video> controlsList
    Electron 问题
    含神经网络的离线AI翻译 APP

    (转载)移动Web开发技巧汇总
    2014年总结
    转载(web app变革之rem)
    火狐不支持backgroundPosition的js插件
  • 原文地址:https://www.cnblogs.com/tiberius/p/9032035.html
Copyright © 2011-2022 走看看