3869 - Elevator Task

Created by Rainel Estrada Montejo
Added by kempachy (2017-06-28)
Limits
Total Time: 25000 MS | Test Time: 1000 MS |Memory: 512 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

There is an elevator that needs to go through a series of floors of one building in a fixed order always starting and ending at first floor every day. This elevator takes exactly 1 second to go between two consecutive floors and takes no time to load and upload passengers on each floor, nor for changing their direction (i.e. going up, or going down).

Given this list of orders can you determine how much time it takes to fulfill all the requests?
Hay un elevador que necesita ir a través de una serie de pisos de un edificio en un orden predefinido, siempre comenzando y terminando en el primer piso, cada día. Este elevador tarda exactamente 1 segundo para ir entre dos pisos consecutivos y tarda un tiempo nulo (o despreciable) al cargar y descargar pasajeros en cada piso, o al cambiar de dirección (i.e. ir hacia abajo, o ir hacia arriba).

Dada la lista de órdenes que recibe el elevador, ¿puede usted determinar cuánto tiempo tardará en completar todas las órdenes?
There is an elevator that needs to go through a series of floors of one building in a fixed order always starting and ending at first floor every day. This elevator takes exactly 1 second to go between two consecutive floors and takes no time to load and upload passengers on each floor, nor for changing their direction (i.e. going up, or going down).

Given this list of orders can you determine how much time it takes to fulfill all the requests?

Input specification

The first line will contain a integer T (1 <= T <= 1000), representing the number of request to be fulfilled by the elevator. The next T lines will contain a integer number between 1 and 50 representing the floor of each request. Note that request must be fulfilled in the given order.
La primera línea contendrá un entero T (1 <= T <= 1000), que representa la cantidad de órdenes que deben ser completadas por el elevador. Las siguientes T líneas contienen un número entero entre 1 y 50 que representa el piso de cada orden. Note que las órdenes deben ser completadas en el orden que fueron dadas.
;jsessionid=E010B24297507914FDAC3FEA455C805C
The first line will contain a integer T (1 <= T <= 1000), representing the number of request to be fulfilled by the elevator. The next T lines will contain a integer number between 1 and 50 representing the floor of each request. Note that request must be fulfilled in the given order.

Output specification

Output a integer number representing the time needed by the elevator to fulfill all the requests.
Usted debe imprimir un número entero que representa el tiempo que necesita el elevador para completar todos los pedidos.
The first line will contain a integer T (1 <= T <= 1000), representing the number of request to be fulfilled by the elevator. The next T lines will contain a integer number between 1 and 50 representing the floor of each request. Note that request must be fulfilled in the given order.

Sample input

3
2
5
3

Sample output

8

Hint(s)

http://coj.uci.cu/contest/
http://coj.uci.cu/contest/
http://coj.uci.cu/contest/