시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 87 | 63 | 53 | 71.622% |
The JOI Railways is the only railway company in the Kingdom of JOI. There are N stations numbered from 1 to N along a railway. Currently, two kinds of trains are operated; one is express and the other one is local.
A local train stops at every station. For each i (1 ≤ i < N), by a local train, it takes A minutes from the station i to the station (i + 1).
An express train stops only at the stations S1, S2, ..., SM (1 = S1 < S2 < ... < SM = N). For each i (1 ≤ i < N), by an express train, it takes B minutes from the station i to the station (i + 1).
The JOI Railways plans to operate another kind of trains called “semiexpress.” For each i (1 i < N), by a semiexpress train, it takes C minutes from the station i to the station (i + 1). The stops of semiexpress trains are not yet determined. But they must satisfy the following conditions:
The JOI Railways wants to maximize the number of stations (except for the station 1) to which we can travel from the station 1 within T minutes. The JOI Railways plans to determine the stops of semiexpress trains so that this number is maximized. We do not count the standing time of trains.
When we travel from the station 1 to another station, we can take trains only to the direction where the numbers of stations increase. If several kinds of trains stop at the station i (2 ≦ i ≦ N - 1), you can transfer between any trains which stop at that station.
When the stops of semiexpress trains are determined appropriately, what is the maximum number of stations (except for the station 1) to which we can travel from the station 1 within T minutes?
Given the number of stations of the JOI Railways, the stops of express trains, the speeds of the trains, and maximum travel time, write a program which calculates the maximum number of stations which satisfy the condition on the travel time.
Read the following data from the standard input.
Write one line to the standard output. The output contains the maximum number of stations satisfying the condition on the travel time.
All input data satisfy the following conditions.
There are no additional constraints.
10 3 5 10 3 5 30 1 6 10
8
In this sample input, there are 10 stations of the JOI Railways. An express train stops at three stations 1, 6, 10. Assume that the stops of an semiexpress train are 1, 5, 6, 8, 10. Then, among the stations 2, 3, ..., 10, we can travel from the station 1 to every station except for the station 9 within 30 minutes.
For some i, the travel time and the route from the station 1 to the station i are as follows:
10 3 5 10 3 5 25 1 6 10
7
90 10 12 100000 1000 10000 10000 1 10 20 30 40 50 60 70 80 90
2
12 3 4 10 1 2 30 1 11 12
8
This sample input does not satisfy the constraints of Subtask 1.
300 8 16 345678901 123456789 234567890 12345678901 1 10 77 82 137 210 297 300
72
This sample input does not satisfy the constraints of Subtask 1.
1000000000 2 3000 1000000000 1 2 1000000000 1 1000000000
3000
This sample input does not satisfy the constraints of Subtask 1. Also, this sample input does not satisfy the constraints of Subtask 2.