A. 最大差值

    远端评测题 1000ms 128MiB

最大差值

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

HKE has recently been keen on studying sequences, and once he discovered an interesting problem:

For a sequence A1,A2,⋯ ,AnA_1,A_2,\cdots,A_n, find two indices i,ji, j (1≤i<j≤n1\le i<j\le n) such that Aj−AiA_j-A_i is maximized.

Given this sequence, please find the maximum value of Aj−AiA_j-A_i.

Input Format

The first line contains a positive integer nn. The next nn lines each contain one integer. The integer on the (i+1)(i + 1)-th line is AiA_i.

Output Format

One line, the maximum value of Aj−AiA_j-A_i.

10
1
3
4
6
7
9
10
1
2
9
9

Hint

Constraints

  • For 30%30\% of the testdata, n≤1000n\le1000.
  • For 70%70\% of the testdata, n≤105n\le10^5.
  • For 100%100\% of the testdata: 2≤n≤1062\le n\le 10^6, and AiA_i is within the int range.

Translated by ChatGPT 5

动态规划小测试

未参加
状态
已结束
规则
IOI
题目
4
开始于
2026-8-3 14:30
结束于
2026-8-3 16:30
持续时间
2 小时
主持人
参赛人数
17