QOJ.ac

QOJ

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

#23926. 나이 차이

Estadísticas

문제

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.