Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- #define ppb pop_back
- #define pf push_front
- #define ppf pop_front
- int main()
- {
- _test
- {
- int n, m, k;
- cin>>n>>m>>k;
- vector<int> a(n), b(m);
- for(auto &e: a) cin>>e;
- for(auto &e: b) cin>>e;
- map<int, int> cnta, cntb;
- for(auto e: b) cntb[e]++;
- for(int i=0; i<m; i++) cnta[a[i]]++;
- int ans = 0;
- int c = 0;
- for(auto [e, _]: cntb) c += min(cnta[e], cntb[e]);
- ans += (c >= k);
- for(int i=m; i<n; i++)
- {
- cnta[a[i-m]]--;
- if(cntb[a[i-m]] > cnta[a[i-m]]) c--;
- cnta[a[i]]++;
- if(cnta[a[i]] <= cntb[a[i]]) c++;
- ans += (c >= k);
- }
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement