This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int main() {
int n , k , Q;
cin>>n>>k>>Q;
vector<vector<int>> a(2 , vector<int>(n));
for(int i = 0 ; i < 2 ; i++)
{
for(int j = 0 ; j < n ; j++)
{
cin>>a[i][j];
a[i][j]--;
}
}
vector<vector<bitset<N>>> bs(2 , vector<bitset<N>>(n));
for(int i = 0 ; i < 2 ; i++)
{
for(int j = 0 ; j < k ; j++)
{
bs[i][0][a[i][j]];
}
for(int j = 1 ; j + k - 1 < n ; j++)
{
bs[i][j] = bs[i][j - 1];
bs[i][j][a[i][j - 1]] = 0;
bs[i][j][a[i][j + k - 1]] = 1;
}
}
int ans = 0;
for(int i = 0 ; i + k - 1 < n ; i++)
{
for(int j = 0 ; j + k - 1 < n ; j++)
{
ans = max(ans , (int)(bs[0][i] & bs[1][j]).count());
}
}
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |