Distance & Displacement

Author: Abu Rayhan Ahmad

Problem Setter: Md. Saifur Rahman, Assistant Prof, Dept. Of CSE

Bangladesh University Of Business & Technology

There are two interesting things in physics, they are:

Distance: Distance is the total length covered by a moving object irrespective of the direction of motion. Here only magnitude is needed.

Displacement: Displacement is distance measured in a straight line and in a specified direction. So both magnitude and direction are important. For example:

A car travels 5 km to east and makes a U-turn back to travel a further distance of 3 km. Then: 


I.  Distance Covered: 5 + 3 = 8 km    II. Displacement: 5 - 3 = 2 km

As a programmer write a program that will be used to find distance & displacement of a given entity

Input Format

The first line of input will contain a number N (1<=N<=100), which will denote the number of sample we want to take. The rest lines contain distance and sign of distance for N times. 

Output Format

In output there will be two lines. The first line contains total distance covered by the object and the second line contains the displacement of the object.

Samples

Input
3 12 + 10 + 5 -
Output
DISTANCE: 27 DISPLACEMENT: 17
Limits
Language Time Memory
GNU C 11 1s 512MB
GNU C++ 14 1s 512MB
GNU C++ 11 1s 512MB
PHP 7 1s 1024MB
Java (OpenJDK 8) 1s 4096MB
Statistics
Login To Submit