• 吃糖果hdu2502


    HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。 

    Input第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0<N<=1000000),第二行是N个数,表示N种糖果的数目Mi(0<Mi<=1000000)。 
    Output对于每组数据,输出一行,包含一个"Yes"或者"No"。 
    Sample Input

    2
    3
    4 1 1
    5
    5 4 3 2 1

    Sample Output

    No
    Yes
    
    
            
     
    Please use function scanf

    Hint

    Hint
            wa了三次,,判断的时候忘记减一,QAQ!
     1 #include <iostream>
     2 using namespace std;
     3 #include<string.h>
     4 #include<set>
     5 #include<stdio.h>
     6 #include<math.h>
     7 #include<queue>
     8 #include<map>
     9 #include<algorithm>
    10 #include<cstdio>
    11 #include<cmath>
    12 #include<cstring>
    13 #include <cstdio>
    14 #include <cstdlib>
    15 #include<cstring>
    16 int main()
    17 {
    18     int t;
    19     cin>>t;
    20     while(t--)
    21     {
    22         int n;
    23         cin>>n;
    24         int max1=0;
    25         int s;
    26         long long sum=0;
    27         for(int i=0;i<n;i++)
    28         {
    29             cin>>s;
    30             max1=max(max1,s);
    31             sum+=s;
    32         }
    33         if(n==1&&s==1)
    34         {
    35             cout<<"Yes"<<endl;
    36             continue;
    37         }
    38         if(sum-max1>=max1-1)
    39             cout<<"Yes"<<endl;
    40         else
    41             cout<<"No"<<endl;
    42     }
    43     return 0;
    44 }
    View Code
  • 相关阅读:
    关于unittest框架的传参问题
    爬虫的框架:Scarpy
    Robot Frameworke在python3上搭建环境以及快捷方式的创建
    安装第三方模块报错:read time out
    操作正则表达式遇到的问题
    gil锁 线程队列 线程池
    并发编程
    网络编程传输文件
    粘包现象
    UDP协议下的socket
  • 原文地址:https://www.cnblogs.com/dulute/p/7289197.html
Copyright © 2020-2023  润新知