POJ3224 Go for Lab Cup!

水题,但是题目内容难读懂,累加一遍即可。

Optimal Parking

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7579   Accepted: 4555

Description

When shopping on Long Street, Michael usually parks his car at some random location, and then walks to the stores he needs. Can you help Michael choose a place to park which minimises the distance he needs to walk on his shopping round? Long Street is a straight line, where all positions are integer. You pay for parking in a specific slot, which is an integer position on Long Street. Michael does not want to pay for more than one parking though. He is very strong, and does not mind carrying all the bags around.

Input

The first line of input gives the number of test cases, 1 ≤ t ≤ 100. There are two lines for each test case. The first gives the number of stores Michael wants to visit, 1 ≤ n ≤ 20, and the second gives theirn integer positions on Long Street, 0 ≤ xi ≤ 99.

Output

Output for each test case a line with the minimal distance Michael must walk given optimal parking.

Sample Input

2
4
24 13 89 37
6
7 30 41 14 39 42

Sample Output

152
70

Source

Nordic 2007

 1 //oimonster
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<iostream>
 5 using namespace std;
 6 int a[101][101],s[101];
 7 int main(){
 8     int i,j,n;
 9     scanf("%d",&n);
10     for(i=1;i<=n;i++)
11         for(j=1;j<=n;j++){
12             scanf("%d",&a[i][j]);
13             s[i]+=a[i][j];
14             s[j]+=5-a[i][j];
15         }
16     int max,ans;
17     max=ans=0;
18     for(i=1;i<=n;i++){
19         if(s[i]>max){
20             max=s[i];
21             ans=i;
22         }
23     }
24     printf("%d\n",ans);
25     return 0;
26 }

时间: 2024-12-29 13:21:13

POJ3224 Go for Lab Cup!的相关文章

POJ 3224 Go for Lab Cup!(水题)

[题意简述]:扫描矩阵,哪一行的'3'多,谁就是胜者,可以取参赛. [分析]:题意里已经说了. //260K 0Ms #include<iostream> using namespace std; int main() { int matrix[100][100]; int a[100]; int n; cin>>n; for(int i = 1;i<=n;i++) for(int j = 1;j<=n;j++) cin>>matrix[i][j]; int

Simulation.Lab.Software.SimLab.Composer.2015.v6.1.MACOSX 1CD

CA Spectrum Linux VM 10.01.00.00.103 Linux 2DVD  Tahoe Design HYDROFLO v3.0.0.4 1CD  CA Spectrum Windows VM 10.01.00.00.103 Win64 2DVD  Delcam Exchange 2016 R2 CR 8.3.1005 Win64 1CD  Delcam PowerSHAPE 2016 SP2 Update only 1CD  ESI Group VA One 2015.0

x01.Lab.StoreApp: XP 停服,微软变脸

变脸,川剧的一种表演形式,除了哄哄小孩,似乎别无用处.而川剧变脸从业者何其多也,存在时间何其长也.以如此多的从业者,如此长的时间,来进行科研,其成果一定是斐然吧.推而广之,试问天下谁能敌! 微软变脸,足以改变世界.这次变脸,不仅是形式上的,而且是骨子里的.为适应手机.平板的性能苛求,其应用商店程序是建立在 WinRT 的基础上,而 WinRT 是建立在 COM 基础上.即面向对象,又拥抱底层,可谓鱼与熊掌兼得.不仅如此,其开发者许可,应用商店成立,无一不在显示微软的掌控能力."天下英雄,尽入毂中

Citrix Provisioning Services LAB時出現Unable to contact th database Server

今天在執行PVS LAB時出現下圖 後來發現為SQL連入的要調整如下圖1.Machine Account2.對應DB3.DB權限 如果是用SA帳戶作為本機的SQL,就是調這組帳戶 調完後對應就可以使用PVS 感謝

Lab颜色空间进行颜色提取 及其实现

这段时间在做车灯检测,晚上有些尾灯偏黄色亮度偏弱,仅用灰度度是不够的,经比较了在RGB.HSV.Lab颜色空间下进行颜色提取,发现Lab颜色模型的效果是最好的.下面介绍Lab的原理及其代码实现. Lab颜色模型由三个要素组成,一个要素是亮度(L),a 和b是两个颜色通道.a包括的颜色是从深绿色(低亮度值)到灰色(中亮度值)再到亮粉红色(高亮度值):b是从亮蓝色(低亮度值)到灰色(中亮度值)再到黄色(高亮度值).因此,这种颜色混合后将产生具有明亮效果的色彩.(这段百度的,哈哈 ) RGB转换到La

Lab - Hot Standby Router Protocol

Topology Objective Configure inter-VLAN routing with HSRP to provide redundant, fault-tolerant routing to the internal network. Background Hot Standby Router Protocol (HSRP) is a Cisco-proprietary redundancy protocol for establishing a fault-tolerant

HDU 2289 Cup

Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5597    Accepted Submission(s): 1787 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th

MIT OS lab Makefile 分析

lab1 中的Makefile主要是根目录下的GNUMakefile, kern/Makefrag, boot/Makefrag, 后两者通过include直接包含到GNUMakefile中. 1 # 2 # This makefile system follows the structuring conventions 3 # recommended by Peter Miller in his excellent paper: 4 # 5 # Recursive Make Considere

ZOJ 1584:Sunny Cup 2003 - Preliminary Round(最小生成树&amp;amp;&amp;amp;prim)

Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they