Advertisement
Ahmed_Negm

Untitled

Mar 9th, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<iomanip>
  4. #include<algorithm>
  5. #include<cstdlib>
  6. #include<cstring>
  7. #include<vector>
  8.  
  9. #define ll long long
  10. #define sz(x) int(x.size())
  11. #define all(x) x.begin(),x.end()
  12. using namespace std;
  13.  
  14. void Fast_IO(){
  15.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  16.     #ifndef ONLINE_JUDGE
  17.         freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  18.     #endif
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  
  25. void solve(){
  26.  
  27. int n;
  28. cin>>n;
  29. ll freq[1000005]{};
  30. int counter =0,ans=0;
  31. for(int i =0; i<2*n; i++){
  32.     int x; cin>>x;
  33.     freq[x]++;
  34.     if(freq[x]==1) counter++;
  35.     else counter-=2;
  36.     if(counter>ans) ans=counter;
  37. }
  38. cout<<ans;
  39.  
  40.  
  41. }
  42.  
  43. int main(){
  44.     Fast_IO();
  45. int t =1;
  46. //cin>>t;
  47. while(t--){
  48. solve();
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement