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.