archit1997

Codeforces Round 648 Div 2 Problem C

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