Hoang_Nguyen
@Hoang_Nguyen
Hiệu năng
0,00
#1912
Đã giải
0
Các kỳ thi đang tham gia
0/ 4
Đóng góp
0
🌹
Rose
46#1196
📅
Chuỗi
1
§ giới thiệu
Thông tin
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 1123456
ll a[N], n, q, l, r, k;
map<ll, vector<ll>> mp;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("MOAI.INP","r",stdin);
// freopen("MOAI.OUT","w",stdout);
cin >> n >> q;
for(ll i = 1; i <= n; i++)
{
cin >> a[i];
mp[a[i]].push_back(i);
}
while(q--)
{
cin >> l >> r >> k;
if(mp.find(k) == mp.end())
{
cout << 0 << '\n';
}
else
{
ll x = lower_bound(mp[k].begin(), mp[k].end(), l) - mp[k].begin();
ll y = upper_bound(mp[k].begin(), mp[k].end(), r) - mp[k].begin();
cout << y - x << '\n';
}
}
return 0;
}