12481 - Frog Jumping   

Description

There’re N stones on the river. The height of the i-th stone is hi for 1iN.
Frog Pepe is on the 1-st stone at the beginning and he wants to cross this river with several jumps.
For each jump, Pepe can jump to the (i+1)-th or the (i+2)-th stone from the i-th stone.
The energy cost of jump is |hihj|, where j is the stone to land on.

Because Pepe is too lazy to move, can you help Pepe to find out the minimun energy cost as few jumps as possible to cross the river?

Explantation of Sample I/O:
The mininum energy is 40. There’re 3 routes having the same cost:

  • Stone 1 -> 2 -> 4 -> 5 -> 6, 4 jumps
  • Stone 1 -> 2 -> 4 -> 6, 3 jumps
  • Stone 1 -> 3 -> 5 -> 6, 3 jumps.

Choose jumps as few as possible.
Therefore, the output is 40, 3.

Input

An integer N on the first line.
h1,h2...hN on the second line.

  • 1N25
  • 1hi100,000

Output

On the first line, two integers C and J, which mean the minimun energy cost and the number of jumps.
Remember ‘\n’ on the end of line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss