GlobeX Cup '19 S3 - Ninjaclasher's Wrath

View as PDF

Submit solution

Points: 12 (partial)
Time limit: 0.6s
Memory limit: 128M

Author:
Problem types

You are going on vacation to your local group of exoplanets. In this group, there are N exoplanets lined up in a row. Each exoplanet is an ellipse, consisting of a vertical radius of hi kilometres and a horizontal radius that is infinitesimal. The ith exoplanet is di kilometres away from the i+1th exoplanet.

You plan to travel to each exoplanet, starting with exoplanet 1. On each one, you will stand at the very "top" of the exoplanet, and look to the left (towards exoplanet i1) and to the right (towards exoplanet i+1). You are curious about the largest exoplanet that you can see in both directions. Next, you will continue to exoplanet 2, and so on. The largest exoplanet is defined as the exoplanet with the largest vertical radius.

Note: Exoplanets are solid objects and you will not be able to see some exoplanets afterward if their vertical radius is not large enough. An exoplanet can be seen even if the tip of it can be seen.

Note 2: Your height is 0 (negligible).

For each exoplanet that you climb up i (1iN), what is the vertical radius of the largest exoplanet when you look left and when you look right?

Input Specification

The first line will contain the integer N (1N2×105), the number of exoplanets.

The second line will contain N integers, hi (1hi109).

The third line will contain N1 integers, di (1di109,1i<N), the distance between exoplanet i and i+1.

Output Specification

Print N lines. On the ith line, print two integers, the vertical radius of the largest exoplanet when looking left (towards exoplanet i1) followed by the vertical radius of the largest exoplanet when looking right (towards exoplanet i+1). If there is no exoplanet to the left/right, output -1.

Subtasks

Subtask 1 [6%]

N1000
hi,di100

Subtask 2 [27%]

hi,di100

Subtask 3 [67%]

No additional constraints.

Sample Input 1

Copy
6
5 2 3 1 4 6
1 1 1 1 1

Sample Output 1

Copy
-1 6
5 6
5 6
3 4
5 6
5 -1

Explanation For Sample 1

When you are on exoplanet 2, the vertical radius of the largest exoplanet you can see to the left is exoplanet 1, which has a vertical radius of 5, and to the right is exoplanet 6, which has a vertical radius of 6. This is illustrated below with the dashed blue and red lines.

Only the top half of each exoplanet is shown.


Comments

There are no comments at the moment.