Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. system ("color B");
  11. setlocale(LC_ALL, "rus");
  12. ios_base::sync_with_stdio(0);
  13.  
  14. int n, r = 0;
  15. cin >> n;
  16. for (r = 0; r < n; r++)
  17. {
  18. int a;
  19. cin >> a;
  20. vector <long long> v;
  21. for (int i = 0; i < a; i++)
  22. {
  23. long long c;
  24. cin >> c;
  25. v.push_back(c);
  26. }
  27. for (int i = 0; i < a; i++)
  28. {
  29. sort(v.begin(), v.end());
  30. for (int j = 1; j < a; j++)
  31. {
  32. if (v[j] == v[j - 1] && v[j] != 2048)
  33. {
  34. v[j] *= 2;
  35. v[j - 1] = 1;
  36. }
  37. }
  38. }
  39. int t = 0;
  40. for (int i = 0; i < a; i++)
  41. {
  42. if (v[i] == 2048)
  43. t++;
  44. }
  45. if(t == 0)
  46. cout << "NO" << endl;
  47. else
  48. cout << "YES" << endl;
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement