-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmfreq.cpp
More file actions
38 lines (34 loc) · 700 Bytes
/
mfreq.cpp
File metadata and controls
38 lines (34 loc) · 700 Bytes
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
#include<bits/stdc++.h>
#define MAX 1000000
#define DEBUG(x) do { std::cout << #x << ": " << x << " "; } while (0)
using namespace std;
int main()
{
unsigned int num[MAX];
int k,l,r,ans,x,temp,m,n,i,j;
cin>>n>>m;
for(i=0;i<n;++i){
cin>>num[i];
}
for(int z=0;z<m;++z){
cin>>l>>r>>k;
l--;
r--;
temp=1;
for(i=l;i<r && temp<k;++i){
x=num[i];
if(num[i+1]!=num[i]){
temp=1;
}
++temp;
}
//cout<<temp<<" ";
if(temp>=k){
cout<<x<<endl;
}
else{
cout<<"-1\n";
}
}
return 0;
}