标签:
SAMPLE INPUT 3 2 2 2 1 1 5 1 4 1 2 3 4 5 4 10 3 1 2 3 4 SAMPLE OUTPUT 1 0 15
题目链接:http://ifrog.cc/acm/problem/1014?contest=1001&no=0
*************************************
错误代码:
1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<queue> 5 #include<algorithm> 6 #include<time.h> 7 #include<stack> 8 using namespace std; 9 #define N 120000 10 #define INF 0x3f3f3f3f 11 12 int a[N]; 13 14 int main() 15 { 16 int T,n,m,k,i; 17 18 scanf("%d", &T); 19 20 while(T--) 21 { 22 scanf("%d %d %d", &n,&m,&k); 23 24 for(i=0; i<n; i++) 25 scanf("%d", &a[i]); 26 27 sort(a,a+n); 28 29 int i=0,sum=0; 30 while(i<n) 31 { 32 if(m-a[i]>0) 33 sum+=m-a[i]; 34 i+=k; 35 } 36 printf("%d\n",sum); 37 } 38 39 return 0; 40 }
“玲珑杯”ACM比赛 Round #1 A -- Absolute Defeat
标签:
原文地址:http://www.cnblogs.com/weiyuan/p/5790673.html