-
Notifications
You must be signed in to change notification settings - Fork 2
/
Solution.java
39 lines (33 loc) Β· 1.27 KB
/
Solution.java
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
38
39
package Iterations.swea6485;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Solution {
static int T, N, A, B, P, C;
static int[] bus;
public static void main(String[] args) throws Exception {
System.setIn(new FileInputStream("src/Iterations/swea6485/s_input.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
T = Integer.parseInt(br.readLine());
for (int t = 1; t <= T; t++) {
bus = new int[5001];
N = Integer.parseInt(br.readLine());
while (N-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
A = Integer.parseInt(st.nextToken());
B = Integer.parseInt(st.nextToken());
for (int j = A; j <= B; j++) bus[j] ++;
}
sb.append("#").append(t).append(" ");
P = Integer.parseInt(br.readLine());
while (P-- > 0) {
C = Integer.parseInt(br.readLine());
sb.append(bus[C]).append(" ");
}
sb.append("\n");
}
System.out.println(sb.toString());
}
}