CF1436A.Reorder
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For a given array a consisting of n integers and a given integer m find if it is possible to reorder elements of the array a in such a way that ∑i=1n∑j=injaj equals m ? It is forbidden to delete elements as well as insert new elements. Please note that no rounding occurs during division, for example, 25=2.5 .
输入格式
The first line contains a single integer t — the number of test cases ( 1≤t≤100 ). The test cases follow, each in two lines.
The first line of a test case contains two integers n and m ( 1≤n≤100 , 0≤m≤106 ). The second line contains integers a1,a2,…,an ( 0≤ai≤106 ) — the elements of the array.
输出格式
For each test case print "YES", if it is possible to reorder the elements of the array in such a way that the given formula gives the given value, and "NO" otherwise.
输入输出样例
输入#1
2 3 8 2 5 1 4 4 0 1 2 3
输出#1
YES NO
说明/提示
In the first test case one of the reorders could be [1,2,5] . The sum is equal to (11+22+35)+(22+35)+(35)=8 . The brackets denote the inner sum ∑j=injaj , while the summation of brackets corresponds to the sum over i .