QOJ.ac

QOJ

時間限制: 1.5 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#12113. 城市

统计

周日清晨,Rauan 踏上了一项重要的任务。为了找到他的朋友 Hafiz,他沿着 M-36 公路从努尔苏丹(Nur-Sultan)开车前往阿拉木图(Almaty)。Rauan 的摩托车油箱容量无限,但他毕竟还是一名大学生,因此他希望尽可能减少开支。

M-36 公路沿线有 $n$ 个定居点,编号从 $1$ 到 $n$。Rauan 的摩托车在两个相邻定居点之间行驶需要消耗 $1$ 个伪升(pseudo-liter)燃料。在城市 $i$ 加油的价格为每伪升 $a_i$ 坚戈(tenge)。

初始时,油箱是空的。Rauan 从第 $s$ 个城市(努尔苏丹)出发,想要到达编号为 $t$ 的城市(阿拉木图)。请帮助 Rauan 计算他完成旅程所需的最少燃料费用。

输入格式

第一行包含三个整数 $n, s, t$ ($1 \le s, t \le n \le 10^6$)。

第二行包含 $n$ 个整数 $a_1, \dots, a_n$ ($0 \le a_i \le 10^9$)。

输出格式

输出一个整数,表示 Rauan 到达城市 $t$ 所需的最少燃料费用(单位:坚戈)。

子任务

本题包含 7 个子任务:

  1. 样例测试。分值 0 分。
  2. $a_1 = a_2 = \dots = a_n$。分值 12 分。
  3. $s = 1$。分值 13 分。
  4. $n \le 2000$。分值 20 分。
  5. $a_1 \le a_2 \le \dots \le a_n$。分值 15 分。
  6. $n \le 10^5$。分值 25 分。
  7. 题目给出的数据范围。分值 15 分。

样例

样例输入 1

5 1 5
5 3 4 2 1

样例输出 1

13

样例输入 2

5 4 2
3 2 5 5 1

样例输出 2

8

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.