Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- int main()
- {
- ll x, n;
- cin >> x >> n;
- vector<ll> z1(x);
- for (int i = 0; i < x; i++)
- {
- cin >> z1.at(i);
- }
- sort(z1.begin(), z1.end());
- if (n == 1)
- {
- map<ll, ll> sl;
- for (int i = 0; i < x; i++)
- {
- if (z1.at(i) <= 7777)
- {
- sl[z1.at(i)] += 2;
- sl[7777 - z1.at(i)] += 1;
- }
- }
- for (auto zb : sl)
- {
- if (zb.second == 3)
- {
- cout << "Yes" << endl;
- return 0;
- }
- }
- cout << "No" << endl;
- }
- else if (n == 2)
- {
- for (int i = 0; i < x - 1; i++)
- {
- if (z1.at(i) == z1.at(i + 1))
- {
- cout << "Contains duplicate" << endl;
- return 0;
- }
- }
- cout << "Unique" << endl;
- }
- else if (n == 3)
- {
- int w = x / 2;
- map<ll, ll> sl;
- for (int i = 0; i < x; i++)
- {
- sl[z1.at(i)] += 1;
- }
- for (auto pp : sl)
- {
- if (pp.second > w)
- {
- cout << pp.first << endl;
- return 0;
- }
- }
- cout << -1 << endl;
- }
- else if (n == 4)
- {
- if (x == 0)
- {
- return 0;
- }
- if (x % 2 == 0)
- {
- cout << z1.at(x / 2 - 1) << " " << z1.at(x / 2) << endl;
- }
- else
- {
- cout << z1.at(x / 2) << endl;
- }
- }
- else if (n == 5)
- {
- for (int i = 0; i < x; i++)
- {
- if (z1.at(i) >= 100 && z1.at(i) <= 999)
- {
- cout << z1.at(i) << " " << endl;
- }
- }
- cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment