zoukankan      html  css  js  c++  java
  • HDU 5835 Danganronpa

    先不管神秘物品,看看把所有物品排成一排最长有多长。然后再搞搞就可以了。

    数据谁了,自己造了1组数据。

    T=1,n=1,a[1]=10000,ans=1

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-8;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    template <class T>
    inline void read(T &x)
    {
        char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
        while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }
    }
    
    int T,n,a,sum,len;
    
    int main()
    {
        scanf("%d",&T); int cas=1; while(T--)
        {
            sum=len=0;
            scanf("%d",&n); priority_queue<int>Q;
            for(int i=1;i<=n;i++) { scanf("%d",&a); sum=sum+a; Q.push(a); }
            printf("Case #%d: ",cas++);
            if(sum<2) {printf("1
    "); continue;}
            while(Q.size()>=2)
            {
                int t1=Q.top(); Q.pop();
                int t2=Q.top(); Q.pop();
                len=len+2*t2; t1=t1-t2; if(t1>0) Q.push(t1);
            }
            if(len==0) len=1;
            if(len<=sum-len) printf("%d
    ",len);
            else printf("%d
    ",sum-len+(len-(sum-len))/2);
        }
        return 0;
    }
  • 相关阅读:
    数组
    Fiddler抓手机APP包
    APP测试注意点-安装卸载与运行
    【转】查看iOS崩溃日志
    Monkey 命令
    python del 函数
    探索性测试方法
    解决5037端口占用的方法
    App测试Android的闪退总结
    Jenkins邮件配置
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5782077.html
Copyright © 2011-2022 走看看