Input:
Code: Select all
9 14
3 4 2 5
1 2 9 1
6 5 9 1
7 6 5 5
7 2 1 1
2 9 22 24
1 8 0 1
23 44 3 97
11 10 85 14
9 1
10 1
10 2
9 2
0 1
0 23
0 3
0 4
3 97
10 20
95 5
90 10
99 2
98 2
0 0
Code: Select all
4
1
1
4
1
8
3
4
7
2
2
2
1
2
Moderator: Board moderators
Code: Select all
9 14
3 4 2 5
1 2 9 1
6 5 9 1
7 6 5 5
7 2 1 1
2 9 22 24
1 8 0 1
23 44 3 97
11 10 85 14
9 1
10 1
10 2
9 2
0 1
0 23
0 3
0 4
3 97
10 20
95 5
90 10
99 2
98 2
0 0
Code: Select all
4
1
1
4
1
8
3
4
7
2
2
2
1
2
Code: Select all
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String[] s = br.readLine().split(" ");
int a = Integer.parseInt(s[0]);
int b = Integer.parseInt(s[1]);
if (a == 0 && b == 0) {
break;
}
int[] start = new int[a];
int[] duration = new int[a];
int[] end = new int[a];
int x = 0, y = 1;
while (x < a) {
s = br.readLine().split(" +");
start[x] = Integer.parseInt(s[2]);
duration[x] = Integer.parseInt(s[3]);
end[x] = start[x] + duration[x];
x++;
}
int count = 0;
while (y <= b) {
count = 0;
s = br.readLine().split(" +");
for (int i = 0; i < a; i++) {
if (Integer.parseInt(s[1]) != 0) {
if (Integer.parseInt(s[0]) < end[i] && (Integer.parseInt(s[0]) + Integer.parseInt(s[1])) > start[i]) {
count++;
}
}
}
y++;
System.out.println(count);
}
}
}
}