博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[解题报告]10041 - Vito's Family
阅读量:6576 次
发布时间:2019-06-24

本文共 1264 字,大约阅读时间需要 4 分钟。

 

  Problem C: Vito's family 

 

Background 

The world-known gangster Vito Deadstone is moving to New York. He has a very big family there, all of them living in Lamafia Avenue. Since he will visit all his relatives very often, he is trying to find a house close to them.

 

Problem 

Vito wants to minimize the total distance to all of them and has blackmailed you to write a program that solves his problem.

 

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) $s_1, s_2, \ldots, s_i, \ldots, s_r$ where they live ( 0 < si < 30000 ). Note that several relatives could live in the same street number.

 

Output 

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

 

Sample Input 

22 2 4 3 2 4 6

Sample Output 

24

 


Miguel Revilla 
2000-11-19
 
 
 
冒泡排序,求中位数,再求解
 
 
#include
int main(){ int k,n,i,j; int temp,s,sum,b; int a[30000]; scanf("%d",&k); while(k--) { sum=0; scanf("%d",&n); for(i=0;i

 

转载于:https://www.cnblogs.com/TheLaughingMan/archive/2013/02/24/2926980.html

你可能感兴趣的文章
TCP(Socket基础编程)
查看>>
RowSet的使用
查看>>
每日一记--cookie
查看>>
WPF and Silverlight 学习笔记(十二):WPF Panel内容模型、Decorator内容模型及其他...
查看>>
IOS 7 Study - UISegmentedControl
查看>>
八、通用类型系统
查看>>
JQuery的ajaxFileUpload的使用
查看>>
关于Integer类中parseInt()和valueOf()方法的区别以及int和String类性的转换.以及String类valueOf()方法...
查看>>
ios 控制器的生命周期
查看>>
C#动态代理
查看>>
使用 sessionStorage 创建一个本地存储的 name/value
查看>>
Python笔记8----DataFrame(二维)
查看>>
JavaScript 特殊效果代码
查看>>
【?】codeforces721E Road to Home(DP+单调队列)
查看>>
MySQL 仅保留7天、一个月数据
查看>>
Win7下安装Mysql(解压缩版)
查看>>
UVA 11992 Fast Matrix Operations (降维)
查看>>
增加临时表空间组Oracle11g单实例
查看>>
Diff Two Arrays
查看>>
stark组件(1):动态生成URL
查看>>