fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. ll t,n,x,s,d,T;
  5. int main(){
  6. freopen("CANDY.INP","r",stdin);
  7. freopen("CANDY.OUT","w",stdout);
  8. cin >> t;
  9. for(ll i=1 ; i<=t ; i++){
  10. cin >> n >> x;
  11. vector <ll> a(n+1);
  12. s=x;
  13. for(ll i=1 ; i<=n ; i++){
  14. cin >> a[i];
  15. s+=a[i];
  16. }
  17. d=0;
  18. T=s/(n+1);
  19. for(ll i=1 ; i<=n ; i++){
  20. if(a[i]<T){
  21. d+=(T-a[i]);
  22. }
  23. }
  24. if(s%(n+1)==0 && x-d==T){
  25. cout <<"YES" << endl;
  26. }
  27. else{
  28. cout <<"NO" << endl;
  29. }
  30. }
  31. }
  32.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty