JOI '16 Final P2 - Semiexpress

View as PDF

Submit solution

Points: 12
Time limit: 1.0s
Memory limit: 512M

Problem types

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 \le 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 S_1, S_2, \dots, S_M (1 = S_1 < S_2 < \dots < S_M = N). For each i (1 \le 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 \le 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:

  • Semiexpress trains must stop at every station where express trains stop.
  • Semiexpress trains must stop at K stations exactly.

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 \le i \le 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?

Task

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.

Input Specification

Read the following data from the standard input.

  • The first line of input contains three space separated integers N, M, K. This means there are N stations of the JOI Railways, an express train stops at M stations, and a semiexpress train stops at K stations.

  • The second line of input contains three space separated integers A, B, C. This means it takes A, B, C minutes by a local, express, semiexpress train to travel from a station to the next station, respectively.

  • The third line of input contains an integer T. This means 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 i-th line (1 \le i \le M) of the following M lines contains an integer S_i. This means an express train stops at the station S_i.

Output Specification

Write one line to the standard output. The output contains the maximum number of stations satisfying the condition on the travel time.

Constraints

All input data satisfy the following conditions.

  • 2 \le N \le 1\,000\,000\,000.
  • 2 \le M \le K \le 3\,000.
  • K \le N.
  • 1 \le B < C < A \le 1\,000\,000\,000.
  • 1 \le T \le 10^{18}.
  • 1 = S_1 < S_2 < \dots < S_M = N.

Subtasks

Subtask 1 [18 points]

The following conditions are satisfied:

  • N \le 300.
  • K-M = 2.
  • A \le 1\,000\,000.
  • T \le 1\,000\,000\,000.
Subtask 2 [30 points]
  • N \le 300.
Subtask 3 [52 points]

No additional constraints.

Sample Input 1

10 3 5
10 3 5
30
1
6
10

Sample Output 1

8

Sample Input 2

10 3 5
10 3 5
25
1
6
10

Sample Output 2

7

Sample Input 3

90 10 12
100000 1000 10000
10000
1
10
20
30
40
50
60
70
80
90

Sample Output 3

2

Comments

There are no comments at the moment.