zoukankan      html  css  js  c++  java
  • ZROI#1003

    ZROI#1003

    这题显然可以(Theta(n imes max_{value}))模拟.
    也显然可以简单的解决(m=1)(m=0)的部分分.
    (m=0)排个序从小到大直接计算即可.(m=1)需要考虑用哪一种魔法.
    显然,怪物个数大于等于(3)个一定是(AOE)魔爆术比较优.
    如果只有一个怪,直接神圣惩击.
    两个怪要讨论,如果一个怪只有一滴血肯定魔爆比较优.否则神惩.
    延续上面的考虑方法,我们如此贪心即可.
    只要剩下的怪大于等于三个,就魔爆.
    小于等于两个的情况参照上面的讨论即可.
    于是,我们可以用堆维护,也可以用什么别的奇技淫巧.
    但不管哪种方法,魔爆的影响肯定不能直接暴力修改.
    正常人都应该会维护一个全局标记吧.
    我选择了堆,但我的做法和上述做法有些许不同.
    而且我能把自己叉掉,但是它(A)了...我就不管了
    (Hack:)
    (Input:)

    3 10
    1 4 4
    

    (Output:)

    5
    

    (Wrong :Answer:)

    6
    

    (Code:)

    #include <algorithm>
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <queue>
    #include <cmath>
    #include <ctime>
    #include <map>
    #include <set>
    #define MEM(x,y) memset ( x , y , sizeof ( x ) )
    #define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
    #define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
    #define pii pair < int , int >
    #define X first
    #define Y second
    #define rint read<int>
    #define int long long
    #define pb push_back
    
    using std::queue ;
    using std::set ;
    using std::pair ;
    using std::max ;
    using std::min ;
    using std::priority_queue ;
    using std::vector ;
    using std::swap ;
    using std::sort ;
    using std::unique ;
    using std::greater ;
    
    template < class T >
        inline T read () {
            T x = 0 , f = 1 ; char ch = getchar () ;
            while ( ch < '0' || ch > '9' ) {
                if ( ch == '-' ) f = - 1 ;
                ch = getchar () ;
            }
           while ( ch >= '0' && ch <= '9' ) {
                x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
                ch = getchar () ;
           }
       return f * x ;
    }
    
    const int N = 1e5 + 100 ;
    priority_queue < int , vector < int > , greater < int > > q ;
    int n , m , tag , ans , v[N] ;
    
    signed main (int argc , char * argv[]) {
        n = rint () ; m = rint () ;
        rep ( i , 1 , n ) { v[i] = rint () ; q.push ( v[i] ) ; }
        while ( ! q.empty () ) {
            if ( m ) {
                -- m ;
                if ( q.size () >= 3 ) {
                    ++ tag ; while ( q.top () - tag <= 0 ) q.pop () ;
                    ans += q.size () ;
                } else {
                    int tmp = q.top () ; q.pop () ;
                    if ( tmp - tag <= 1 ) {
                        ans += q.size () ;
                        ++ m ; continue ;
                    }
                    if ( tmp - tag > 2 ) q.push ( tmp - 2 ) ;
                    ans += q.size () ;
                }
            } else {
                int tmp = q.top () ;
                ans += q.size () * ( tmp - tag - 1 ) + q.size () - 1 ;
                q.pop () ;
            }
        }
        printf ("%lld
    " , ans ) ;
        return 0 ;
    }
    
    May you return with a young heart after years of fighting.
  • 相关阅读:
    Building workspace has encountered a proble
    Eclipse异常关闭,IDE Exception Handler has encountered a problem An internal error has occurred
    jsp中写java代码的方法
    如何在jsp里面写java代码
    jsp中在java里面怎么调文本框里面的值?
    Typescript基本认识
    运行flutter run 报错Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
    H5+原生webview实现APP的JavascriptBridge的使用
    vue mounted里使用window.onresize报错问题
    关于elmentui 抽屉 el-drawer 的slot插入的内容无法通过ref访问的问题
  • 原文地址:https://www.cnblogs.com/Equinox-Flower/p/11523759.html
Copyright © 2011-2022 走看看