Advertisement
MohamedAbdel3al

A. Andryusha and Socks

Sep 21st, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 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.  
  18. int main() {
  19. ABDEL3AL() ;
  20. int n , cnt = 0 , Max = imin ;
  21. cin >> n ;
  22. int arr[n] , freq[n + 1] = {0} ;
  23. for (int i = 0; i < n * 2; i++) {
  24. cin >> arr[i] , freq[arr[i]]++ ;
  25. cnt++ ;
  26. if (freq[arr[i]] == 2) cnt -= 2 ;
  27. Max = max (cnt , Max) ;
  28. }
  29. cout << Max ;
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement