A:DESCRIPTION
Eric has an array of integers a1,a2,...,ana1,a2,...,an. Every time, he can choose a contiguous subsequence of length kk and increase every integer in the contiguous subsequence by 11. He wants the minimum value of the array is at least mm. Help him find the minimum number of operations needed.
INPUT
There are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case: The first line contains three integers nn, mm and kk (1≤n≤105,1≤k≤n,1≤m≤104)(1≤n≤105,1≤k≤n,1≤m≤104). The second line contains nn integers a1,a2,...,ana1,a2,...,an (1≤ai≤104)(1≤ai≤104).
OUTPUT
For each test case, output an integer denoting the minimum number of operations needed.
SAMPLE INPUT SAMPLE OUTPUT
题目链接:http://ifrog.cc/acm/problem/1014?contest=1001&no=0
*************************************
错误代码:(貌似错的还挺离谱,没办法,太弱了)
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<time.h>
#include<stack>
using namespace std;
#define N 120000
#define INF 0x3f3f3f3f int a[N]; int main()
{
int T,n,m,k,i; scanf("%d", &T); while(T--)
{
scanf("%d %d %d", &n,&m,&k); for(i=; i<n; i++)
scanf("%d", &a[i]); sort(a,a+n); int i=,sum=;
while(i<n)
{
if(m-a[i]>)
sum+=m-a[i];
i+=k;
}
printf("%d\n",sum);
} return ;
}
比赛全部的题从链接里面找,有兴趣的可以自己做做看。下面是全部题解: