QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100

#23926. 年齡差

統計

題目描述

JOI 市有編號為 $1$ 到 $N$ 的 $N$ 名居民,居民 $i$($1 \le i \le N$)的年齡為 $A_i$ 歲。

給定 JOI 市居民的年齡 $A_1, A_2, \dots, A_N$。請撰寫程式,對於每個 $i = 1, 2, \dots, N$,求出居民 $i$ 與其他居民之間年齡差的最大值。

限制條件

  • $2 \le N \le 250000$。
  • $0 \le A_i \le 10^9$($1 \le i \le N$)。
  • 輸入的所有值皆為整數。

子任務

  1. ($25$ 分)$N = 2$。
  2. ($30$ 分)$N \le 1000$。
  3. ($45$ 分)無額外限制條件。

輸入格式

輸入以如下格式給出:

$N$ $A_1 \ A_2 \ \dots \ A_N$

輸出格式

輸出 $N$ 行。第 $i$ 行($1 \le i \le N$)輸出居民 $i$ 與其他居民之間年齡差的最大值。

範例

範例輸入 1

3
13 15 20

範例輸出 1

7
5
7
  • 居民 $1$ 與居民 $2, 3$ 的年齡差分別為 $2, 7$ 歲。其中的最大值為 $7$ 歲,因此第 $1$ 行輸出 $7$。
  • 居民 $2$ 與居民 $1, 3$ 的年齡差分別為 $2, 5$ 歲。其中的最大值為 $5$ 歲,因此第 $2$ 行輸出 $5$。
  • 居民 $3$ 與居民 $1, 2$ 的年齡差分別為 $7, 5$ 歲。其中的最大值為 $7$ 歲,因此第 $3$ 行輸出 $7$。

本範例輸入滿足子任務 $2, 3$ 的限制條件。

範例輸入 2

2
100 100

範例輸出 2

0
0
  • 居民 $1$ 與居民 $2$ 的年齡差為 $0$ 歲。因此,第 $1$ 行輸出 $0$。
  • 居民 $2$ 與居民 $1$ 的年齡差為 $0$ 歲。因此,第 $2$ 行輸出 $0$。

本範例輸入滿足所有子任務的限制條件。

範例輸入 3

10
440894064 101089692 556439322 34369336 98417847 216265879 623843484 554560874 247445405 718003331

範例輸出 3

406524728
616913639
522069986
683633995
619585484
501737452
589474148
520191538
470557926
683633995

本範例輸入滿足子任務 $2, 3$ 的限制條件。

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.