Advertisement
Tahsin24

Untitled

Oct 7th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. /*
  2.  
  3. verdict : wrong answer
  4. October challenge
  5. Problem : Chef and Ground
  6.  
  7. */
  8. #include <iostream>
  9. #include <algorithm>
  10. #include <cstdlib>
  11. #include <cstring>
  12. #include <string>
  13. #include <vector>
  14. #include <cstdio>
  15. #include <cmath>
  16. using namespace std;
  17. int main()
  18. {
  19. int T;
  20. cin >> T;
  21. int n, m, num;
  22. vector <int> v;
  23. while (T--)
  24. {
  25. v.clear();
  26. cin >> n >> m;
  27. for (int i = 0; i < n; i++)
  28. {
  29. cin >> num;
  30. v.push_back(num);
  31. }
  32. sort(v.begin(), v.end());
  33. int biggest_num = v[n - 1];
  34. int total_diff = 0;
  35. for(int i = 0; i < n; i++)
  36. {
  37. total_diff += biggest_num - v[i];
  38. }
  39. int flag = 0;
  40. if(m < total_diff)
  41. {
  42. cout << "NO" << endl;
  43. flag = 1;
  44. //cout << 1 << endl;
  45. }
  46. else if (total_diff == m)
  47. {
  48. cout << "YES" << endl;
  49. flag = 1;
  50. //cout << 2 << endl;
  51. }
  52. else
  53. {
  54. while (total_diff <= m)
  55. {
  56. total_diff += n;
  57. //cout << total_diff << endl;
  58. if (total_diff == m)
  59. {
  60. cout << "YES" << endl;
  61. //cout << 3 << endl;
  62. flag = 1;
  63. break;
  64. }
  65. }
  66.  
  67. }
  68. if (flag == 0)
  69. {
  70. cout << "NO" << endl;
  71. //cout << 4 << endl;
  72. }
  73.  
  74. }
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement