Two remote monitoring probes each schedule a single numeric reading to become available after a known delay. Probe A's reading becomes available after t1 seconds with value v1; probe B's reading becomes available after t2 seconds with value v2. A fusion controller waits until both readings have arrived and then reports their sum as the fused reading. Given the two delays and their two values, determine the time at which the fused reading becomes available and the value of that fused reading.
A single line containing four integers: t1 v1 t2 v2 — probe A's delay and value, followed by probe B's delay and value.
Print two integers on one line, separated by a space: the time the fused reading becomes available (the later of the two delays), followed by the fused value (the sum of the two readings).
Example 1
Input
0 5 0 7
Expected
0 12
Explanation
Both probes report instantly (delay 0), so the fused reading is available at time 0, and its value is 5 + 7 = 12.
Example 2
Input
3 -2 7 10
Expected
7 8
Explanation
Probe A's reading (-2) is ready at t=3, but probe B's reading (10) isn't ready until t=7, so the fusion controller must wait until t=7; the fused value is -2 + 10 = 8.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →