CF939C.Convenient For Everybody

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.

Some online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a__i people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.

Help platform select such an hour, that the number of people who will participate in the contest is maximum.

在遥远的未来,地球上的每一天持续 nn 小时,因此共有 nn 个时区。相邻时区的本地时间相差 1 小时。本地时间用 11 到 nn 的整数表示(即不存在“0 点”,而是用“nn 点”代替)。当第 1 个时区的本地时间为 1 点时,第 ii 个时区的本地时间为 ii 点。

某个在线编程竞赛平台希望举办一场持续 1 小时的比赛,并要求比赛开始时间恰好与某一整点时刻重合(在所有时区中均如此)。平台已知:有 aia_i 名用户来自第 ii 个时区,且希望参加该比赛。每位用户仅当比赛在其本地时间 不早于 ss 点 00 分开始、且 不晚于 ff 点 00 分结束时,才会参加。参数 ss 和 ff 对所有时区均相同。若比赛在其本地时间恰好于 ff 点 00 分开始,则该用户不会参加。

请帮助平台选择一个开始时刻(以某整点为准),使得参赛人数最多。

输入格式

The first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.

The second line contains n space-separated integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 10 000), where a__i is the number of people in the i-th timezone who want to participate in the contest.

The third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).

第一行包含一个整数 nn(2≤n≤100 0002 \leq n \leq 100\,000)—— 表示一天中的小时数。

第二行包含 nn 个用空格分隔的整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤10 0001 \leq a_i \leq 10\,000),其中 aia_i 表示第 ii 个时区中希望参加比赛的人数。

第三行包含两个用空格分隔的整数 ss 和 ff(1≤s<f≤n1 \leq s < f \leq n)。

输出格式

Output a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.

输出一个整数——即比赛开始时间(以第一个时区的当地时间表示),使得参赛者人数达到最大可能值。若存在多个满足条件的答案,则输出其中最小的一个。

输入输出样例

  • 输入#1

    3
    1 2 3
    1 3

    输出#1

    3
  • 输入#2

    5
    1 2 3 4 1
    1 3

    输出#2

    4

说明/提示

In the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.

In second example only people from the third and the fourth timezones will participate.

在第一个例子中,最佳策略是在第 3 小时(即第一个时区)开始比赛。此时,第二个时区为第 1 小时,第三个时区为第 2 小时。只有第一个时区的一个人不会参加。

在第二个例子中,只有第三个和第四个时区的人会参加。

输入解题思路,AI测评打分。不知道怎么写?

首页