fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define ld long double
  7.  
  8. void Free_palestine() {
  9. ios::sync_with_stdio(false);
  10. cin.tie(NULL);
  11. cout.tie(NULL);
  12. }
  13.  
  14. const int N = 2e5 + 5;
  15. const int MOD = 1e9 + 7;
  16. const int MAXN = 1005;
  17. int a[MAXN];
  18.  
  19. signed main(){
  20. Free_palestine();
  21.  
  22. int n, q;
  23. cin >> n >> q;
  24.  
  25.  
  26. for (int i = 1; i <= n; i++) {
  27. cin >> a[i];
  28. }
  29.  
  30.  
  31. while (q--) {
  32. int l, r, x;
  33. cin >> l >> r >> x;
  34.  
  35. int count = 0;
  36. for (int i = l; i <= r; i++) {
  37. if (a[i] == x) {
  38. count++;
  39. }
  40. }
  41.  
  42. cout << count << "\n";
  43. }
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5320KB
stdin
8 6
1 6 5 7 9 9 1 6
1 8 9
5 6 9
6 6 9
7 8 6
1 8 1
2 3 1
stdout
2
2
1
1
2
0