CF 243  DIV1 & DIV2

 

DIV2的A和B都太水,直接暴力搞就可以的。

DIV2A

 1 /* ***********************************************
 2 Author        :kuangbin
 3 Created Time  :2014/4/30 19:42:51
 4 File Name     :E:\2014ACM\Codeforces\CF243\DIV2_A.cpp
 5 ************************************************ */
 6 
 7 #include <stdio.h>
 8 #include <string.h>
 9 #include <iostream>
10 #include <algorithm>
11 #include <vector>
12 #include <queue>
13 #include <set>
14 #include <map>
15 #include <string>
16 #include <math.h>
17 #include <stdlib.h>
18 #include <time.h>
19 using namespace std;
20 
21 int a[110];
22 int main()
23 {
24     //freopen("in.txt","r",stdin);
25     //freopen("out.txt","w",stdout);
26     int n,s;
27     while(scanf("%d%d",&n,&s) == 2)
28     {
29         for(int i = 0;i < n;i++)
30             scanf("%d",&a[i]);
31         sort(a,a+n);
32         int ans = 0;
33         for(int i = 0;i < n-1;i++)
34             ans += a[i];
35         if(ans <= s)printf("YES\n");
36         else printf("NO\n");
37     }
38     return 0;
39 }
View Code

相关文章: