PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000052. Takahashi nhảy xa 2 (Jumping Takahashi 2)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Takahashi nhảy xa 2 (Jumping Takahashi 2)
Jumping Takahashi 2
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Trampoline i is located at (x_i,y_i) and has power p_i. With integer training level S, a jump i to j is possible if S*p_i is at least their Manhattan distance. Minimize S so that some starting trampoline can reach every other trampoline.
Input
First n; then n lines x_i y_i p_i.
Output
Print the minimum required nonnegative integer S.
Subtasks
- Subtask 1 (40 points): . All coordinates (x_i,y_i) are pairwise distinct. All input values are integers.
- Subtask 2 (60 points): $2\le n\le 200,\ |x_i|,|y_i|\le 10^9,\ 1\le p_i\le 10^9$. All coordinates (x_i,y_i) are pairwise distinct. All input values are integers.
Examples
Input
3
0 0 1
2 0 1
4 0 1
Output
2
Explanation
At S=1 no jump can cross the two-unit gap. At S=2, starting at trampoline 1 reaches all via 1→2→3.