第 475 场 AtCoder Beginner Contest
C
沿线行走
Walk the Line
AtCoder
⌀ 549
原题
← BD →

沿线行走AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

There are $N$ towns arranged in a line. The towns are numbered $1, 2, \ldots, N$, and for each integer $i$ satisfying $1 \leq i \leq N-1$, town $i$ and town $i + 1$ are connected by a road of length $A_i$.

有 $N$ 个城镇排成一条直线,编号为 $1, 2, \ldots, N$。对于满足 $1 \leq i \leq N-1$ 的每个整数 $i$,城镇 $i$ 和城镇 $i + 1$ 之间有一条长度为 $A_i$ 的道路。AI (CI翻译)

You are initially at town $S$. You can repeatedly move between two towns connected by a road using that road.

你最初位于城镇 $S$。你可以反复沿着道路在两个相连的城镇之间移动。AI (CI翻译)

Find the maximum possible number of towns visited in a sequence of moves such that the total distance traveled is at most $L$. Here, town $S$ is included among the towns visited, and a town visited multiple times is counted only once.

求在总行驶距离不超过 $L$ 的前提下,通过一系列移动最多能访问多少个城镇。这里,城镇 $S$ 也计入访问过的城镇;重复访问同一个城镇只计一次。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $2 \leq N \leq 8000$
  • $1 \leq S \leq N$
  • $0 \leq L \leq 10^{18}$
  • $1 \leq A_i \leq 10^9$
  • All input values are integers.
  • $2 \leq N \leq 8000$
  • $1 \leq S \leq N$
  • $0 \leq L \leq 10^{18}$
  • $1 \leq A_i \leq 10^9$
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

N S L
A_1 A_2 \ldots A_{N - 1}

N S L
A_1 A_2 \ldots A_{N - 1}
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the answer.

输出答案。AI (CI翻译)

样例

Input #1
6 3 10
5 2 4 1 6
Output #1
4
You are initially at town $3$. If you move in the order town $3 \to 2 \to 3 \to 4 \to 5$, the total distance traveled is $2 + 2 + 4 + 1 = 9$, and the towns visited are $2, 3, 4, 5$, that is, four towns. It is impossible to visit five or more towns with a total travel distance of at most $10$, so the answer for this case is $4$.
Input #2
8 8 17
2 3 4 4 3 5 1
Output #2
6
Input #3
2 1 1000000000000000000
10000
Output #3
2
Input #4
9 6 28
5 4 9 2 3 6 1 4
Output #4
6
题目信息
题号
abc475_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。