QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 512 MB Puntuación total: 100

#6210. Lighthouse

Estadísticas

JSOI is a small country located in a hilly region. For border defense, the King wishes to build a lighthouse on one of the mountain peaks along the border to illuminate the entire border. The research work for the lighthouse construction has been entrusted to JYY.

JSOI has $N$ consecutive mountain peaks along its border, where the height of the $i$-th peak is $h_i$. For simplicity, we assume these $N$ peaks are arranged in a straight line.

If a lighthouse of height $p$ ($p \ge 0$) is built on the $i$-th peak, JYY has discovered that this lighthouse can illuminate the $j$-th peak if and only if the following inequality is satisfied:

$$h_j \le h_i + p + \sqrt{|i - j|}$$

The King of JSOI wants JYY to provide the minimum height required for a lighthouse built on each peak such that it can illuminate all other peaks. Can you help JYY?

Input

The input contains a positive integer $N$. The next $N$ lines each contain a positive integer $h_i$, representing the height of the $i$-th peak.

Output

Output $N$ lines, where the $i$-th line contains a non-negative integer representing the minimum height $p_i$ required to build a lighthouse on the $i$-th peak.

Constraints

  • For 30% of the data, $N \le 1000$.
  • For 60% of the data, $N \le 20000$.
  • For 100% of the data, $1 < N \le 10^5$, $0 < h_i \le 10^9$.

Examples

Input 1

6
5
3
2
4
2
4

Output 1

2
3
5
3
5
4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.