| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 91 | 62 | 55 | 67.073% |
On a scenic coastline, there are $N$ skyscrapers arranged in a line. For each building $i$ (from $1$ to $N$), we know its distance from the sea, $L_i$, and its height, $H_i$. We can model the top of each building as a point in a 2D plane at coordinates $(L_i, H_i)$. The buildings are sorted by their distance from the sea, so it's guaranteed that $L_i < L_{i+1}$ for all $1 \le i < N$.
You are a professional skydiver and have planned a spectacular dive for $Q$ different days. On the $i$-th day ($1 \le i \le Q$), you are given a planned dive location, which is a horizontal coordinate $d_i$. It is guaranteed that no building is located exactly at $d_i$.
To prepare for the $i$-th day's dive, you must perform the following setup:
Being a cautious professional, you want to minimize the risk associated with high altitudes. Therefore, for each dive, you must choose the pair of buildings $(l, r)$ that results in the lowest possible altitude for the rope at your jump-off coordinate $d_i$.
Note that the rope is an idealized line segment. It is allowed to pass through or intersect with other buildings; its path is determined only by the two chosen endpoints.
For each of the $Q$ planned dives, find this minimum possible altitude.
The first line contains a single integer $N$ — the number of buildings.
The next $N$ lines describe the buildings. The $i$-th of these lines contains two integers, $L_i$ and $H_i$ — the distance from the sea and the height of the $i$-th building. It is guaranteed that $L_1 < L_2 < \dots < L_N$.
The next line contains a single integer $Q$ — the number of planned diving days.
The next $Q$ lines describe the planned dives. The $i$-th of these lines contains a single integer $d_i$ — the horizontal coordinate for that day's dive. It is guaranteed that $d$ will not be equal to any $L_i$.
For each of the $Q$ dives, output a single line containing two space-separated integers, $s$ and $t$. These two integers must represent the minimum possible starting altitude as an irreducible fraction $s/t$. If the denominator is $1$, you should still print it.
4 1 4 4 3 7 5 11 2 7 2 3 5 6 8 9 10
11 3 10 3 20 7 19 7 17 7 16 7 15 7
4 1 1 3 3 5 5 7 7 3 2 4 6
2 1 4 1 6 1
University > KAIST > KAIST ICPC Mock Competition > 2025 KAIST 15th ICPC Mock Competition F번
University > MIT > The MIT Programming Contest > 2025-26 > MIT Team Contest 2 F번