2016 CCPC-Final

The Third Cup is Free

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 inline int read()
 5 {
 6     int x=0,f=1;char ch=getchar();
 7     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
 8     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
 9     return x*f;
10 }
11 
12 /********************************************************************/
13 
14 const int maxn = 1e5+7;
15 int a[maxn];
16 
17 bool cmp(int x, int y){
18     return x > y;
19 }
20 
21 int main(){
22     int t; t = read();
23     int cnt = 0;
24     while(t--){
25         cnt++;
26         int n; n = read();
27         for(int i = 1;i <= n;i++){
28             a[i] = read();
29         }
30         sort(a+1, a+1+n, cmp);
31         int ans = 0;
32         for(int i = 1;i <= n;i++){
33             if(i%3 == 0) continue;
34             ans += a[i];
35         }
36         printf("Case #%d: %d\n", cnt, ans);
37     }
38     return 0;
39 }
View Code

猜你喜欢

转载自www.cnblogs.com/ouyang_wsgwz/p/9765501.html