#ABC475C. 沿线行走 / Walk the Line
沿线行走 / Walk the Line
Problem Statement
There are towns arranged in a line. The towns are numbered , and for each integer satisfying , town and town are connected by a road of length .
You are initially at town . You can repeatedly move between two towns connected by a road using that road.
Find the maximum possible number of towns visited in a sequence of moves such that the total distance traveled is at most . Here, town is included among the towns visited, and a town visited multiple times is counted only once.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the answer.
6 3 10
5 2 4 1 6
4
You are initially at town . If you move in the order town , the total distance traveled is , and the towns visited are , that is, four towns.
It is impossible to visit five or more towns with a total travel distance of at most , so the answer for this case is .
8 8 17
2 3 4 4 3 5 1
6
2 1 1000000000000000000
10000
2
9 6 28
5 4 9 2 3 6 1 4
6
- Source: AtCoder ABC 475 C
相关
在下列比赛中: