描述 Description
First line of input contains an integer T denoting number of test cases.
Then for each test case, The first line contains two integers N and M.
The second line contains N space-separated integers A1, A2, …, AN denoting the initial heights of the columns“.
输出格式 OutputFormat
If Chef can spend all cubes and make the columns equal print Yes else print No.
样例输入 SampleInput
3
5 7
3 3 4 2 1
5 6
3 3 4 2 1
5 8
3 3 4 2 1
样例输出 SampleOutput
Yes
No
No
水。
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int i,j,t,n,m,l,r,k,z,y,x;
int a[105];
int h,T;
int main()
{
scanf("%d",&T);
while (T--)
{
scanf("%d%d",&n,&m);
h=0;
for (i=1;i<=n;i++) scanf("%d",&a[i]),h=max(h,a[i]);
t=0;
for (i=1;i<=n;i++) t+=h-a[i];
if (m<t || (m-t)%n!=0)
{
printf("No\n");
continue;
}
printf("Yes\n");
}
return 0;
}