-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlike.cpp
More file actions
38 lines (32 loc) · 720 Bytes
/
like.cpp
File metadata and controls
38 lines (32 loc) · 720 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
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main()
{
int n;
cin >> n;
int *favor = new int[n+1]();
unordered_multimap<int, int> fmap;
for (int i = 1; i <= n; i++)
{
cin >> favor[i];
fmap.insert(make_pair(favor[i], i));
}
int q;
cin >> q;
vector<int> ans;
while (q--)
{
int l, r, k, cnt = 0;
cin >> l >> r >> k;
auto range = fmap.equal_range(k);
for (auto i = range.first; i != range.second; i++)
if (i->second >= l && i->second <= r)
++cnt;
ans.push_back(cnt);
}
for (auto i : ans)
cout << i << endl;
return 0;
}