Water problem, but the topic content is difficult to read, add up again can. 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 is integer. The parking in a specific slot, which are an integer position on Long Street. Michael does not want to pay for more than one parking though. He is very strong, and does don't mind carrying all the bags around.
Input
The first line of input gives the number of test cases, 1≤ T ≤100. There is and lines for each test case. The first gives the number of stores Michael wants to visit, 1≤ n ≤20, and the second gives theirn int Eger 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
2424 13 89 3767 30 41 14 39 42
Sample Output
15270
Source
Nordic 2007
1 //Oimonster2#include <cstdio>3#include <cstdlib>4#include <iostream>5 using namespacestd;6 inta[101][101],s[101];7 intMain () {8 intI,j,n;9scanf"%d",&n);Ten for(i=1; i<=n;i++) One for(j=1; j<=n;j++){ Ascanf"%d",&a[i][j]); -s[i]+=A[i][j]; -s[j]+=5-A[i][j]; the } - intMax,ans; -max=ans=0; - for(i=1; i<=n;i++){ + if(s[i]>max) { -max=S[i]; +cn1=i; A } at } -printf"%d\n", ans); - return 0; -}
View Code
POJ3224 Go for Lab cup!