Advertisement
MegaVerkruzo

a

Sep 10th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <unordered_map>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int n;
  10. cin >> n;
  11. unordered_map<long long, int> d;
  12. for (int i = 0; i < n; ++i) {
  13. int x;
  14. cin >> x;
  15. d[x]++;
  16. }
  17. vector<int> ans;
  18. for (auto e : d) {
  19. if (ans.size() == n / 2) {
  20. break;
  21. }
  22. while (e.second > 0) {
  23. if (e.first % 3 == 0) {
  24. if (d[e.first / 3 * 4] > 0) {
  25. ans.push_back(e.first);
  26. e.second--;
  27. d[e.first / 3 * 4]--;
  28. }
  29. }
  30. else {
  31. break;
  32. }
  33. }
  34. }
  35. for (int i = 0; i < ans.size(); ++i) {
  36. cout << ans[i] << "\n";
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement