Quick actions

cmd+k|ctrl+k

Navigation

Languages

Рамка Карло

Snippet info

Language

Cpp

Visibility

public

Author

vovapskov

Created

2025-10-31T17:05:54.252366Z

Updated

2025-10-31T17:19:08.882893Z

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int &x : a) {
		cin >> x;
	}
	sort(a.begin(), a.end());
	for (int d : a) {
		cout << d << " ";
	}
	cout << '\n';
	vector<int> v;
	int i = 0;
	while (i < n - 1) {
		if (a[i] != a[i + 1]) {
			i += 1;
		} else {
			v.push_back(a[i]);
			i += 2;
		}	
	}
	for (int t : v) {
		cout << t << " ";
	}
	cout << '\n';
	int z = v.size();
	if (z < 2) {
		cout << -1;
	} else {
		cout << v[z - 1] << '\n';
		int s = v[z - 2] * v[z - 1];
		cout << s;
	}
}
INFO