fork download
  1. import java.io.*;
  2. import java.util.*;
  3. class Ideone{
  4. //jump to main function line no. 30
  5. static class Fast{
  6. Fast() throws IOException{
  7. st=new StringTokenizer(br.readLine());
  8.  
  9. }
  10. String next() throws IOException {
  11. return (st.hasMoreElements()?st.nextToken():(st=new StringTokenizer(br.readLine())).nextToken());
  12. }
  13. int nextInt() throws IOException{
  14. return Integer.parseInt(next());
  15. }
  16. long nextLong() throws IOException{
  17. return Long.parseLong(next());
  18. }
  19. void print(Object o) throws IOException{
  20. String s=String.valueOf(o);
  21. bw.write(s);
  22. bw.flush();
  23. }
  24. }
  25. public static void main(String args[]) throws IOException {
  26. Fast f=new Fast();
  27. int t=f.nextInt();
  28. while(t--!=0){
  29. int n=f.nextInt();
  30. int arr[][]=new int[2][n];
  31. for(int i=0;i<n;i++){
  32. arr[0][i]=f.nextInt();
  33. arr[1][i]=f.nextInt();
  34. }
  35. int q=f.nextInt();
  36. //queries in q[] reading and printing parallely
  37. int qr[]=new int[q];
  38. for(int i=0;i<q;i++){
  39. qr[i]=f.nextInt();
  40. int id=qr[i];
  41. int count=0;
  42. for(int j=0;j<n;j++){
  43. if(id>=arr[0][j] && id<=arr[1][j]){
  44. count++;
  45. }
  46. }
  47. f.print(count + "\n");
  48. }
  49. }
  50. }
  51. }
  52.  
Success #stdin #stdout 0.12s 48196KB
stdin
1
4
1 3
1 6
3 5
5 9
4
3
8
6
10
stdout
3
1
2
0