mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 2083.cpp
This commit is contained in:
parent
e5a33246e5
commit
cd39793b4b
54
HDOJ/2083.cpp
Normal file
54
HDOJ/2083.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <stack>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <climits>
|
||||
|
||||
/// This Contest and Compile does not support C++11.
|
||||
//#include <thread>
|
||||
//#include <mutex>
|
||||
//#include <condition_variable>
|
||||
//#include <functional>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int m;
|
||||
cin>>m;
|
||||
for(int i=0;i<m;i++)
|
||||
{
|
||||
int n;
|
||||
cin>>n;
|
||||
vector<int> vec;
|
||||
for(int j=0;j<n;j++)
|
||||
{
|
||||
int temp;
|
||||
cin>>temp;
|
||||
vec.push_back(temp);
|
||||
}
|
||||
|
||||
int minVal=INT_MAX;
|
||||
for(int j=0;j<n;j++)
|
||||
{
|
||||
int sum=0;
|
||||
for(int k=0;k<n;k++)
|
||||
{
|
||||
sum+=abs(vec.at(j)-vec.at(k));
|
||||
}
|
||||
minVal=min(sum,minVal);
|
||||
}
|
||||
|
||||
cout<<minVal<<endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user