No.1282 Display Elements
Problem Statement
A-kun and B-kun each have $\ N\ $ cards.
The $i\ $-th cards have the positive integers $\ a_i,\ b_i\ $ written on them, respectively.
The two will now repeat the following operation. The $i\ $-th operation $(i=1,\ 2,\ \dots,\ N)$ is as follows.
・B-kun places his $\ i\ $-th card on the field. Then A-kun chooses one card from those he has not yet chosen and presents it.
・The integer written on the card A-kun presented is compared with the integers written on the cards on the field, one card at a time.
Each time the integer written on the presented card is larger, A-kun gains $\ 1\ $ point.
Find the maximum score A-kun can obtain.
Added at 22:16: The expression "the number on the card" has been changed to "the integer written on the card".
Input
$N$ $a_1\ a_2\ \dots\ a_N$ $b_1\ b_2\ \dots\ b_N$
・All inputs are integers.
・$1 \le N \le 10^5$
・$1 \le a_i, b_i \le 10^9$
Output
Output the maximum score A-kun can obtain.
Sample
Sample 1
Input
2 1 5 3 4
Output
2
First, B-kun places his first card, with $3$ written on it, on the field.
A-kun should present $1$, but he gains no points on turn $1$.
Next, B-kun places his second card, with $4$ written on it, on the field.
A-kun presents his remaining card, with $5$ written on it. This is larger than $3$ and $4$, so he gains $2$ points.
If he presents the cards in the reverse order, he can gain only $1$ point, so output the maximum score, $2$.
Sample 2
Input
3 2 2 2 1 5 3
Output
3
In this case, the result is the same regardless of the order in which the cards are presented.
Sample 3
Input
7 3 10 7 2 5 7 1 8 5 21 9 1 6 4
Output
11
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
platinum
leafirby