T3000

Untitled

May 4th, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5.  
  6. int main()
  7. {
  8.     ll x, n;
  9.     cin >> x >> n;
  10.     vector<ll> z1(x);
  11.  
  12.     for (int i = 0; i < x; i++)
  13.     {
  14.         cin >> z1.at(i);
  15.     }
  16.     sort(z1.begin(), z1.end());
  17.     if (n == 1)
  18.     {
  19.         map<ll, ll> sl;
  20.         for (int i = 0; i < x; i++)
  21.         {
  22.             if (z1.at(i) <= 7777)
  23.             {
  24.                 sl[z1.at(i)] += 2;
  25.                 sl[7777 - z1.at(i)] += 1;
  26.             }
  27.         }
  28.         for (auto zb : sl)
  29.         {
  30.             if (zb.second == 3)
  31.             {
  32.                 cout << "Yes" << endl;
  33.                 return 0;
  34.             }
  35.         }
  36.         cout << "No" << endl;
  37.     }
  38.     else if (n == 2)
  39.     {
  40.         for (int i = 0; i < x - 1; i++)
  41.         {
  42.             if (z1.at(i) == z1.at(i + 1))
  43.             {
  44.                 cout << "Contains duplicate" << endl;
  45.                 return 0;
  46.             }
  47.         }
  48.         cout << "Unique" << endl;
  49.     }
  50.     else if (n == 3)
  51.     {
  52.         int w = x / 2;
  53.         map<ll, ll> sl;
  54.         for (int i = 0; i < x; i++)
  55.         {
  56.             sl[z1.at(i)] += 1;
  57.         }
  58.         for (auto pp : sl)
  59.         {
  60.             if (pp.second > w)
  61.             {
  62.                 cout << pp.first << endl;
  63.                 return 0;
  64.             }
  65.         }
  66.         cout << -1 << endl;
  67.     }
  68.     else if (n == 4)
  69.     {
  70.         if (x == 0)
  71.         {
  72.             return 0;
  73.         }
  74.         if (x % 2 == 0)
  75.         {
  76.             cout << z1.at(x / 2 - 1) << " " << z1.at(x / 2) << endl;
  77.         }
  78.         else
  79.         {
  80.             cout << z1.at(x / 2) << endl;
  81.         }
  82.     }
  83.     else if (n == 5)
  84.     {
  85.         for (int i = 0; i < x; i++)
  86.         {
  87.  
  88.             if (z1.at(i) >= 100 && z1.at(i) <= 999)
  89.             {
  90.                 cout << z1.at(i) << " " << endl;
  91.             }
  92.         }
  93.         cout << '\n';
  94.     }
  95.  
  96.     return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment