Exam
Time limit3sMemory limit1024 MB
For each of Q threshold triples, count students with S>=X, T>=Y, and S+T>=Z, where N and Q reach 100000.
- Level
Hard8 of 10
- Topics
- Sorting, Prefix sum, Binary search, Geometry
- Solved
- No attempts yet
Problem
students took an exam with a mathematics section and an informatics section. The -th student () scored points in mathematics and points in informatics. Professor T and Professor I want to decide, based on the scores, whether each student passes the exam.
- Professor T cares about both subjects. A student passes only if they score at least points in mathematics and at least points in informatics.
- Professor I cares only about the total score. A student passes if their mathematics and informatics scores sum to at least points.
- A student passes the exam only if they satisfy both professors' criteria.
You do not know the thresholds , , . Instead, you are given triples of integers (), and you want to know how many students pass the exam when , , .
Given the students' scores and the score thresholds, find the number of students who pass the exam under these conditions.
Input
The input is given in the following format from standard input. All values are integers.
Output
Print lines to standard output. The -th line () is the number of students who pass the exam when , , .
Constraints
- .
- ().
- ().
- ().
- ().
- ().