Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize ("O3")
- #pragma GCC target ("sse4")
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<int, int> pii;
- typedef pair<string,int> psi;
- typedef vector<int> vi;
- typedef vector<string> vs;
- typedef vector<ll> vll;
- typedef vector<vector<int>> vvi;
- typedef vector<vector<string>> vvs;
- typedef vector<vector<ll>> vvll;
- #define FOR(i, a, b) for (auto i=a; i<=(b); i++)
- #define FORd(i,b,a) for (int i =b; i >= a; i--)
- #define sz(x) (int)(x).size()
- #define mp make_pair
- #define pb push_back
- #define f first
- #define s second
- #define ins insert
- const int MOD = 1000000007;
- //type functions here
- //terminated due to timeout
- int main() {
- int tc;
- cin>>tc;
- FOR(i,1,tc){
- vector<int> v;
- int n,k;
- cin>>n>>k;
- FOR(j,1,n)
- {
- int temp;
- cin>>temp;
- v.pb(temp);
- }
- int min=*min_element(v.begin(),v.end());
- int offset=0;
- if(min<0)
- offset=abs(min);
- map<int,int> m;
- FOR(i,0,n-1)
- {
- m[v[i]+offset]++;
- if(i>=k) m[v[i-k]+offset]--;
- if(i>=k-1)
- {
- int c=0;
- for(auto x:m)
- if(x.s>0) c++;
- cout<<c<<" ";
- }
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement