問題一覧 > 通常問題

No.647 Mentaiko

レベル : / 実行時間制限 : 1ケース 4.500秒 / メモリ制限 : 256 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 342
作問者 : moko_freedom / テスター : ciel
お気に入りにしたユーザー ProblemId : 2103 / 自分の提出
問題文最終更新日: 2026-06-27 11:42:05
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 183 (順位表) の他の問題:

Problem Statement

The Mentaiko Club has $N$ members.
Today is the day of the annual mentaiko party, so the members have decided to go shopping for mentaiko.

The mentaiko direct sales shop sells $M$ kinds of mentaiko. Mentaiko number $i$ costs $X_i$ yen and has spiciness $Y_i$.

When member number $j$ sees a mentaiko that costs at most $A_j$ yen and has spiciness at least $B_j$, the member cannot resist buying it, and always buys exactly one of each kind of mentaiko that meets these conditions. However, being particular about mentaiko, they never buy a mentaiko that fails even one of the two conditions.

The Mentaiko Club has a tradition of naming the mentaiko bought by the most people the "Miracle Mentaiko" and eating it at every meal for a whole year, so they want to know which mentaiko was bought by the most people.

If multiple mentaiko are tied for the most purchased, all of them are chosen as the "Miracle Mentaiko".

On behalf of the Mentaiko Club, find the mentaiko chosen as the "Miracle Mentaiko".

2018/03/18: The time limit has been changed to 4.5 seconds.

Input

$N$
$A_1\ B_1$
$.$
$.$
$A_N\ B_N$
$M$
$X_1\ Y_1$
$.$
$.$
$X_M\ Y_M$

$1 \le N \le 10^4$
$1 \le M \le 10^3$
$1 \le X_i,Y_i,A_i,B_i \le 10^8$

Output

Print the numbers of the mentaiko chosen as the "Miracle Mentaiko" by the Mentaiko Club, one per line, in ascending order.
If no mentaiko was bought by any member of the Mentaiko Club, print 0.
Also, print a newline at the end.

Sample

Sample 1
Input
3
6 4
5 2
2 5
2
4 3
5 4
Output
2

Mentaiko number 1 is bought by member number 2, and mentaiko number 2 is bought by members number 1 and 2.
Member number 3 buys no mentaiko, since no mentaiko meets their conditions.

Sample 2
Input
5
5 7
6 3
4 1
8 6
5 4
3
2 4
6 5
4 2
Output
1

Mentaiko number 1 is bought by members number 2, 3, and 5, mentaiko number 2 is bought by member number 1, and mentaiko number 3 is bought by member number 3.

Sample 3
Input
4
8 6
3 5
4 2
7 3
1
10 2
Output
0

None of the members of the Mentaiko Club can buy any mentaiko.

Sample 4
Input
3
3 4
1 7
5 3
4
1 5
2 6
5 2
6 7
Output
1
2

Mentaiko number 1 and mentaiko number 2 are each bought by 2 members.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。