FHShubho / dauds_family

CSE373 Assignment. This problem is also known as Vito's Family.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Daud's Family

CSE373 - Design and Analysis of Algorithms course assignment.

Fall 2019

This problem is also known as Vito's Family.

1 Background

The famous gangster Daud Ibrahim is moving to Dhaka city. He has a very big family there, all of them living in the Lamafia Avenue, near Bashundhara. Since he will visit all his relatives very often, he wants to find a house close to them. Indeed, Daud wants to minimize the total distance to all of his relatives and has blackmailed you to write a program that solves his problem.

2 Input

The input consists of several test cases. The first line contains the number of test cases. For each test case you will be given the integer number of relatives r (0 < r < 500) and the street numbers (also integers) s1, s2, ..., si, ...., sr where they live (0 < si < 30; 000). Note that several relatives might live at the same street.

3 Output

For each test case, your program must write the minimal sum of distances from the optimal Daud's house to each one of his relatives. The distance between two street numbers siandsj is dij = |si - sj |.

Solution

About

CSE373 Assignment. This problem is also known as Vito's Family.


Languages

Language:C 100.0%