Рамка Карло

Run Settings
LanguageC++
Language Version
Run Command
#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; } }
Editor Settings
Theme
Key bindings
Full width
Lines