-
Notifications
You must be signed in to change notification settings - Fork 6
/
smarket.cpp
62 lines (52 loc) · 1.16 KB
/
smarket.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<bits/stdc++.h>
#define MAX 1000000
#define ll long long
#define DEBUG(x) do { std::cout << #x << ": " << x << " "; } while (0)
using namespace std;
int main()
{
int t,n,q,i,j,l,r,k,x,y,temp,count,ans;
int a[MAX]={0};
int dp[MAX]={0};
cin>>t;
while(t--){
cin>>n>>q;
cin>>a[0];
//dp[0]=count=1;
for(i=1;i<n;++i){
cin>>a[i];
/*if(a[i-1]==a[i]){
++count;
}
else{
count=1;
}
dp[i]=count;*/
}
while(q--){
cin>>l>>r>>k;
l--;
r--;
ans=0;
count=1;
for(i=l+1;i<=r;++i){
if(a[i]==a[i-1]){
++count;
}
else{
if(count>=k){
++ans;
}
count=1;
}
}
if(count>=k)
{
++ans;
}
cout<<ans<<"\n";
}
//cout<<endl;
}
return 0;
}