Ankit_132

A

Sep 25th, 2023
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7.  
  8. int main()
  9. {
  10.     _test
  11.     {
  12.         int n;
  13.         cin>>n;
  14.        
  15.         vector<int> a(n);
  16.         for(auto &e: a)     cin>>e;
  17.        
  18.         vector<int> b;
  19.        
  20.         int x = 1;
  21.        
  22.         for(int i=0; i<n; i++)
  23.         {
  24.             while(a[i] == x)        x++;
  25.             b.push_back(x);
  26.             x++;
  27.         }
  28.        
  29.         cout<<b.back()<<"\n";
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment