This page is still under construction.

Parts of this page are still being built. What you see may change.

Airport Coffee

Time limit6sMemory limit512 MB

Summary
Given spaced coffee carts along a corridor, choose where to buy cups so the total walking time with alternating slow and fast phases is minimized, output as a fraction.
Level

Hard8 of 10

Topics
Dynamic programming, Greedy, Prefix sum, Math
Solved
No attempts yet

Problem

Jonna flies to programming contests. She lives in Helsinki, so she usually has to reach a large hub first, for example Copenhagen Airport, and take a connecting flight from there. Flights run late all the time, and a late flight hurts most when a connection is waiting.

Jonna has just landed at Copenhagen Airport and has to catch her connection to Heathrow Airport. Her flight from Helsinki was delayed, so she has to walk quickly from the arrival gate to the departure gate. Jonna normally walks aa centimeters per second. There is one complication: she is slightly addicted to coffee, and she drags her feet when she is not drinking any. The coffee itself does nothing for her legs, but the grumpiness of not drinking it beats even the fear of a missed flight. While she is drinking coffee she walks bb centimeters per second.

The arrival gate and the departure gate are ℓ\ell centimeters apart, and nn small coffee carts stand along the way. Paying with a contactless card is instant, so buying a cup takes no time, but the coffee is too hot to drink right away. For tt seconds after the purchase Jonna waits for the cup to cool down and keeps walking at the slow speed. Exactly tt seconds after the purchase she starts drinking, and emptying the cup takes exactly rr seconds, during which she walks at the fast speed. Once the cup is empty she walks slowly again.

Jonna carries a bag in her left hand, so she can hold only one cup at a time. She may throw away a cup that still contains coffee and buy a fresh one, wasteful as that is.

Jonna never stops walking, and she can buy coffee only at a cart, at the moment she passes it. Find the shortest time she needs to reach the departure gate.

Input

The first line contains five integers ℓ\ell, aa, bb, tt and rr.

  • 1≤ℓ≤10111 \le \ell \le 10^{11} is the distance between the arrival gate and the departure gate in centimeters.
  • 1≤a<b≤2001 \le a < b \le 200 are Jonna's walking speeds in centimeters per second, first while she is not drinking coffee and then while she is drinking coffee.
  • 0≤t≤3000 \le t \le 300 is the number of seconds she has to wait before she can drink a cup.
  • 1≤r≤12001 \le r \le 1200 is the number of seconds it takes her to empty a cup.

The second line contains one integer nn, the number of coffee carts between the two gates (0≤n≤5000000 \le n \le 500000).

The third line contains nn integers, the positions of the coffee carts as distances from the arrival gate in centimeters, in ascending order. Every position is between 00 and ℓ\ell inclusive, and no two carts share a position. The third line is empty when n=0n = 0.

Output

Print the shortest time in seconds that Jonna needs to reach the departure gate. That time is always a rational number, so print it as the irreducible fraction p/qp/q, where q≥1q \ge 1 and the greatest common divisor of pp and qq is 11. When the time is a whole number of seconds, qq is 11, so a time of 40 seconds is printed as 40/1.

Note

The figure illustrates the first example. The carts where Jonna buys coffee are marked with triangles, and the dotted parts are the stretches she walks faster because she is drinking. She buys at the carts 50005000 and 5500055000 centimeters from the arrival gate. The first cup cools down 1100011000 centimeters from the start, the second one 6100061000 centimeters from the start. She walks 8040080400 of the 100000100000 centimeters while drinking, so the total time is 19600/100+80400/138=17908/2319600/100 + 80400/138 = 17908/23 seconds. Buying at the carts 50005000 and 5000050000 takes exactly as long, and the printed answer is the same.

Examples2

  1. Example 1

    Input
    100000 100 138 60 300
    5
    5000 20000 50000 55000 75000
    
    Expected output
    17908/23
    
  2. Example 2

    Input
    100000 78 86 9 560
    4
    13505 69705 87448 92090
    
    Expected output
    1994494/1677