#include <bits/stdc++.h> using namespace std; int ar[300002]; int main() { #ifdef De
freopen("../../toutiao_1/data/a.in", "r", stdin); //输入重定向,输入数据将从in.txt文件中读取 #endif int n, m; while (~scanf("%d", &n)) { for (int i = 1; i <=n; ++i) {
scanf("%d", &ar[i]); //输入单值 }
scanf("%d", &m); while (m--){ int start,end,target; scanf("%d %d %d",&start,&end,&target); int count = 0; for(int i=start;i<=end;++i){ if(ar[i]==target)
count++; }
cout<<count<<endl; }
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in); int n = in.nextInt(); Map<Integer,List<Integer>> map = new HashMap<Integer, List<Integer>>(n); List<Integer> list; for(int i=1; i<=n; i++){ int ki = in.nextInt(); if(map.containsKey(ki)){
list = map.get(ki); list.add(i); }else{
list = new ArrayList<Integer>(); list.add(i); map.put(ki,list); }
} int count; int q = in.nextInt(); for(int i=0; i<q; i++){ int l = in.nextInt(); int r = in.nextInt(); int k = in.nextInt(); count = 0; if(!map.containsKey(k)){
System.out.println(count); continue; }
list = map.get(k); for(Integer num : list){ if(num>=l && num<=r){
count++; }
}
System.out.println(count); }
}
我这样暴搜也没超,还AC了