No.3085 Easy Problems
タグ : / 解いたユーザー数 132
作問者 :
amentorimaru
Story
Yu~-san is a blue coder, yet could not solve a certain gray-difficulty problem set in a certain ABC.
"Yes, um, I misread it..."
In other words, no matter how low the difficulty is, a problem in a field one is weak at is not easy for that person.
"Huh? No, it's not about weak fields, I misread it."
Let's count how many "easy problems" there are that even Yu~-san can solve.
"I told you, I just misread it!!"
Problem Statement
There are $N$ problems, numbered $1,2,\dots ,N$ in order.
Problem $i$ has difficulty $A_i$ and field $B_i$.
Separately, there are $Q$ people, numbered $1,2,\dots ,Q$ in order.
Person $i$ has intelligence $X_i$ and weak field $Y_i$.
For every pair of natural numbers $(s,t)$ satisfying $1\le s \le N,1\le t \le Q$, problem $s$ is an easy problem for person $t$ when $A_s \le X_t$ and $B_s \neq Y_t$.
For each $k=1,2,\dots ,Q$, find how many of the $N$ problems are easy for person $k$.
Input
$N$ $A_1\ B_1$ $A_2\ B_2$ $\vdots$ $A_N\ B_N$ $Q$ $X_1\ Y_1$ $X_2\ Y_2$ $\vdots$ $X_Q\ Y_Q$
Constraints
- $1\le N,Q \le 2\times 10^5$
- $1\le A_i,X_i \le 10^9$
- $1\le B_i,Y_i \le 10^5$
- All inputs are integers.
Output
Output $Q$ lines. On the $i$-th line, output the number of problems that are easy for person $i$.
Print a newline at the end.Sample
Sample 1
Input
5 5 1 3 2 10 2 1 3 2 3 3 4 1 2 3 1000 2
Output
3 0 3
The easy problems for person $1$ are problems $2,4,5$.
There are no easy problems for person $2$.
Person $3$ has high intelligence, but problems $2,3$ are in their weak field, so they are not easy problems for that person.
Sample 2
Input
3 5 1 50 1 500 1 3 5 2 50 2 500 1
Output
1 2 0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。