#SRD0000139. Kỳ thi (Examination)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Kỳ thi (Examination)
Examination
Source: Japanese Olympiad in Informatics
Version: Phuoc Hung OJ Extended
Problem Statement
There are students in an examination with two subjects: mathematics and informatics. Student scores points in mathematics and points in informatics.
Two professors jointly decide the passing criteria. The first professor requires a student to score at least in mathematics and at least in informatics, simultaneously. The second professor requires a student's combined score to be at least . A student passes only if all three conditions are satisfied.
The thresholds are not fixed. There are possible criteria; criterion is a triple corresponding to , , .
For each criterion, count students simultaneously satisfying
$$S_i\ge X_j,\qquad T_i\ge Y_j,\qquad S_i+T_i\ge Z_j.$$The students' scores never change, and each criterion is evaluated independently.
Input
- The first line contains integers : the number of students and the number of criteria.
- Each of the next lines contains integers , the mathematics and informatics scores of student .
- Each of the final lines contains integers , the required thresholds for criterion .
Output
Print lines. Line is the number of students meeting all three thresholds of criterion .
Subtasks
- Subtask 1 (2 points): ; ; for all valid indices.
- Subtask 2 (20 points): ; ; for all valid indices.
- Subtask 3 (21 points): ; ; for all valid indices.
- Subtask 4 (57 points): ; ; for all valid indices.
Examples
Example 1
Input
5 4
35 100
70 70
45 15
80 40
20 95
20 50 120
10 10 100
60 60 80
0 100 100
Output
2
4
1
1
Explanation
The five score pairs are . For thresholds , students and qualify with combined scores and ; student and student fail the informatics threshold, and student has combined score only : answer . For , everyone but student (total ) passes: . For , only student satisfies both subject thresholds: . For , only student has informatics score : .