Advertisement
MohamedAbdel3al

D. The first missing number

Sep 20th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. #define all(v) v.begin() , v.end()
  6. #define imin INT_MIN
  7. #define imax INT_MAX
  8. typedef long long ll ;
  9.  
  10. void ABDEL3AL () {
  11. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  12. #ifndef ONLINE_JUDGE
  13. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  14. #endif
  15. }
  16.  
  17. int main() {
  18. ABDEL3AL() ;
  19. int n , m ; cin >> n >> m ;
  20. int arr[n] ;
  21. map <int , int> freq ;
  22. for (int i = -m; i >= m; i++) {
  23. freq[i] = 0 ;
  24. }
  25. for (int i = 0; i < n; i++) cin >> arr[i] , freq[arr[i]]++ ;
  26. int x ;
  27. for (auto & i : freq)
  28. if (i.second == 0) return cout << i.first , 0 ;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement