#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,ans,temp;
int visited[201];
vector<int>v;
void find(){
do{
for(int i=2; i<=n; i++){
temp+=abs(v[i-2]-v[i-1]);
}
ans=max(ans,temp);
temp=0;
}
while(next_permutation(v.begin(),v.end()));
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=0; i<n; i++){
int inp; cin>>inp;
v.push_back(inp);
}
sort(v.begin(),v.end());
find();
cout<<ans;
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 10823๋ฒ - ๋ํ๊ธฐ2 (0) | 2021.10.24 |
---|---|
[๋ฐฑ์ค,c++] 10822๋ฒ - ๋ํ๊ธฐ (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10820๋ฒ - ๋ฌธ์์ด ๋ถ์ (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10818๋ฒ - ์ต์, ์ต๋ (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10817๋ฒ - ์ธ ์ (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10816๋ฒ - ์ซ์์นด๋ 2 (0) | 2021.10.24 |
๋๊ธ