Advertisement
archit1997

Codeforces Round 648 Div 2 Problem C

Jun 7th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. //Archit Singh
  2. //architsingh456@gmail.com
  3. //GitHub : archit-1997
  4.  
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7.  
  8. #define ll      long long int
  9. #define ld      long double
  10. #define line    cout<<"-------------"<<endl;
  11. #define F       first
  12. #define S       second
  13. #define P       pair<ll,ll>
  14. #define PP      pair<pair<ll,ll>,ll>
  15. #define V       vector<ll>
  16. #define VP      vector<pair<ll,ll>>
  17. #define VS      vector<string>
  18. #define VV      vector<vector<ll>>
  19. #define VVP     vector<vector<pair<ll,ll>>>
  20. #define pb      push_back
  21. #define pf      push_front
  22. #define PQ      priority_queue<ll>
  23. #define PQ_G    priority_queue<ll,vector<ll>,greater<ll>>
  24. #define line    cout<<"-------------"<<endl;
  25. #define mod     1000000007
  26. #define inf     1e18
  27.  
  28. #define setbits(x)      __builtin_popcount(x)
  29. #define zerobits(x)     __builtin_ctzll(x)
  30. #define ps(x,y)         fixed<<setprecision(y)<<x
  31. #define w(x)            ll x; cin>>x; while(x--)
  32. #define FOR(i,a,b)      for(ll i=a;i<b;i++)
  33. #define ma(arr,n,type)  type *arr=new type[n]
  34.  
  35. void init()
  36. {
  37.     ios_base::sync_with_stdio(false);
  38.     cin.tie(NULL); cout.tie(NULL);
  39.  
  40.     //freopen("input.txt", "r", stdin);
  41.     //freopen("output.txt", "w", stdout);
  42. }
  43.  
  44. int main()
  45. {
  46.  
  47.     init();
  48.  
  49.     ll n;   cin >> n;
  50.  
  51.     V a(n, 0), b(n, 0), index(n, 0), left(n, 0), right(n, 0);
  52.  
  53.     FOR(i, 0, n)
  54.     cin >> a[i];
  55.  
  56.     FOR(i, 0, n) {
  57.         cin >> b[i];
  58.         index[b[i]] = i;
  59.     }
  60.  
  61.     FOR(i, 0, n) {
  62.         ll diff = i - index[a[i]];
  63.         if (diff < 0) {
  64.             right[abs(diff)]++;
  65.             left[n - abs(diff)]++;
  66.         }
  67.         else {
  68.             left[diff]++;
  69.             right[n - diff]++;
  70.         }
  71.     }
  72.  
  73.     cout << *max_element(right.begin(), right.end()) << endl;
  74.  
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement