Logo
(追記) (追記ここまで)

26449번 - Harvest 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB67483672.000%

문제

Today is the Age of Agriculture.

As a member of Japan Agriculture Group (JAG), you grow $N$ kinds of plants this year. Each plant has different harvest seasons: the $i$-th plant must be gathered at some day between $s_i$ and $t_i,ドル inclusive.

You plan to gather plants $K$ times, where the $j$-th gathering day is $h_j$. On the $j$-th gethering day, if the $i$-th plant has not been gathered yet and the gathering day is within the harvest season of the $i$-th plant, that is $s_i \le h_j \le t_i,ドル you have to gather the $i$-th plant.

You are not sure whether your planned days are sufficient to gather all the $N$ plants. If not, you would not be able to survive this cruel Age of Agriculture. Thus you decided to write a program to compute the number of plants gathered after $K$ gathering days you planned.

입력

The input consists of a single test case of the following format.

$N$

$s_1$ $t_1$

$\vdots$

$s_N$ $t_N$

$K$

$h_1$

$\vdots$

$h_K$

The first line is the number $N$ of plants you will grow (1ドル \le N \le 10^5$). The $i$-th of the following $N$ lines consists of two integers $s_i$ and $t_i,ドル which represent that the harvest season of the $i$-th plant is $[s_i,t_i]$ (1ドル \le s_i \le t_i \le 10^9$).

The following line contains the number $K$ of the gathering days you plan (1ドル \le K \le 10^5$). The j-th of the following $K$ lines contains an integer $h_j$ (1ドル \le h_j \le 10^9$), which is the $j$-th gathering day you plan. You can assume that holds $h_j < h_{j+1}$ for 1ドル \le j \le K-1$.

출력

Print the number of plants gathered after your planned gathering days.

제한

예제 입력 1

4
1 2
3 3
2 4
7 9
2
3
9

예제 출력 1

3

예제 입력 2

4
1 5
5 10
3 8
5 5
1
5

예제 출력 2

4

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Practice Contest for ICPC Asia Regional > JAG Practice Contest for ICPC 2021 Asia Yokohama Regional A번

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 1: JAGain in Petrozavodsk A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /