Advertisement
Josif_tepe

Untitled

Oct 7th, 2022
1,078
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     int niza[n];
  10.     for (int i = 0; i < n - 1; i++)
  11.     {
  12.         cin >> niza[i];
  13.     }
  14.     if (n == 2)
  15.     {
  16.         if(niza[0] == 1) {
  17.             cout << 2 << endl;
  18.         }
  19.         else {
  20.             cout << 1 << endl;
  21.         }
  22.         return 0;
  23.     }
  24.     sort (niza, niza + n - 1);
  25.     for(int i = 0; i < n - 2; i++)
  26.     {
  27.         if(niza[i + 1] - niza[i] == 1)
  28.         {
  29.  
  30.         }
  31.         else {cout << niza[i + 1] - 1 << endl;
  32.             return 0;
  33.         }
  34.     }
  35.     cout << n << endl;
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement