Skip to content

Instantly share code, notes, and snippets.

@Thiago4532
Created June 18, 2020 06:12
Show Gist options
  • Save Thiago4532/9fbcf3cc7b145ef92e59246c71a81683 to your computer and use it in GitHub Desktop.
Save Thiago4532/9fbcf3cc7b145ef92e59246c71a81683 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 +10, maxv = 1e5 + 10;
int a[maxn], b[maxn];
int v[maxn], x[maxn], freq[maxn];
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int n, resp = 0;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], v[a[i]] = i;
for (int i = 1; i <=n ; i++)
cin >> b[i];
for (int i = 1; i <= n; i++) {
if ( i <= v[ b[i] ] )
x[ b[i] ] = v[ b[i] ] - i;
else
x[ b[i] ] = v[ b[i] ] - i + n;
//cout << b[i] << ": " << x[b[i]] << " " << v[b[i]] << "\n";
freq[ x[ b[i] ] ]++;
resp = max(resp, freq[x[b[i]]]);
}
cout << resp << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment