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

31488번 - Favourite dish 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB157513530.435%

문제

France is a country of gastronomy. For a dish, both the taste and plating are important. Nevertheless, when different people evaluate a dish, some focus more on taste and some focus more on plating. At the Olympic Village dining hall, there are $N$ dishes, numbered from 1ドル$ to $N$; each dish has a score on its taste and a score on its plating. There are also $M$ persons, numbered from 1ドル$ to $M$; each person has a weight on taste and a weight on plating. One person’s final score of a dish is the weighted average of the dish’s scores on taste and plating.

The chefs at the Olympics want to provide everyone with their favourite dish on the evening of the closing ceremony. Your task is to calculate everyone’s favourite dish. If multiple dishes tie for the highest score as a person’s favourite, choose the one with the smallest number.

입력

Each line contains two space-separated integers. The first line contains the numbers $N$ and $M$. Then follow $N$ lines; the $k$th such line contains two integers $t_k$ and $p_k,ドル which are the scores of the dish $k$ on taste and on plating. Then come $M$ more lines; the $\ell$th such line contains two integers $T_\ell$ and $P_\ell,ドル which are the weights of person $\ell$ on taste and on plating.

출력

The output should contain $M$ lines. The $\ell$th such line should contain one number: the number of the favourite dish of person $\ell$.

제한

  • 1ドル \le N \le 500,円 000$
  • 1ドル \le M \le 500,円 000$
  • 0ドル \le t_k \le 1,円 000,円 000,ドル 0ドル \le p_k \le 1,円 000,円 000,ドル and $(t_k , p_k) \ne (0, 0)$ for all $k \le N$
  • 0ドル \le T_\ell \le 1,円 000,円 000,ドル 0ドル \le P_\ell \le 1,円 000,円 000,ドル and $(T_\ell , P_\ell) \ne (0, 0)$ for all $\ell \le M$
  • the $N$ pairs $(t_k , p_k)$ are pairwise distinct
  • the $M$ pairs $(T_\ell , P_\ell)$ are pairwise distinct

예제 입력 1

4 3
2 5
3 4
4 2
1 6
6 4
2 8
5 5

예제 출력 1

2
4
1

Here is the score table for each person on each dish. Each person’s favourite dish is indicated with a *; person 3 has three tied favourite dishes, so we chose the first one.

예제 입력 2

3 4
1 0
0 2
0 1
1 1
2 2
2 1
1 0

예제 출력 2

2
2
1
1

Here is the score table for each person on each dish. Each person’s favourite dish is indicated with a *.

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2023-2024 G번

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

출처

대학교 대회

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

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