Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- unordered_map<long long, int> d;
- for (int i = 0; i < n; ++i) {
- int x;
- cin >> x;
- d[x]++;
- }
- vector<int> ans;
- for (auto e : d) {
- if (ans.size() == n / 2) {
- break;
- }
- while (e.second > 0) {
- if (e.first % 3 == 0) {
- if (d[e.first / 3 * 4] > 0) {
- ans.push_back(e.first);
- e.second--;
- d[e.first / 3 * 4]--;
- }
- }
- else {
- break;
- }
- }
- }
- for (int i = 0; i < ans.size(); ++i) {
- cout << ans[i] << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement