Language: C++

#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

namespace std{
	template<typename T>
	inline void hash_combine(size_t& seed, T const& v){
		seed ^= hash<T>()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
	}
    template<typename It>
    inline size_t hash_range(It first, It last){
		size_t seed=0;
		hash_range(seed,first,last);
		return seed;
	}
	template<typename It>
	inline void hash_range(size_t& seed, It first, It last){
		for(;first!=last;++first)hash_combine(seed, *first);
	}
	template<typename A,typename B>
	class hash<pair<A,B>>{
		public:
		size_t operator()(pair<A,B> const &p) const{
			size_t seed=0;
			hash_combine(seed,p.first);
			hash_combine(seed,p.second);
			return seed;
		}
	};
	template<typename T,size_t N>
	class hash<array<T,N>>{
		public:
		size_t operator()(array<T,N> const &container) const{
			return hash_range(container.begin(),container.end());
		}
	};
	template<typename T,typename A>
	class hash<vector<T,A>>{
		public:
		size_t operator()(vector<T,A> const &container) const{
			return hash_range(container.begin(),container.end());
		}
	};
}

int main(){
	int N;
	scanf("%d",&N);
	vector<short>v(N);
	for(int i=0;i<N;i++)scanf("%d",&v[i]);
	priority_queue<pair<int,vector<short> > >q;
	unordered_map<vector<short>,int>depth;

	q.push(make_pair(0,v));
	int R;
	for(;!q.empty();){
		pair<int,vector<int> >cur=q.top();
		q.pop();
		if(depth.find(cur.second)!=depth.end())continue;
		depth[cur.second]=cur.first;
		bool f=false;
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(i!=j&&cur.second[i]>cur.second[j]){
			if(i<j)f=true;
			swap(cur.second[i],cur.second[j]);
			q.push(make_pair(cur.first-cur.second[i]-cur.second[j],cur.second));
			swap(cur.second[i],cur.second[j]);
		}
		if(!f){
			R=-cur.first;
			break;
		}
	}
	printf("%d\n",R);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:48: error: conversion from 'pair<[...],vector<short int>>' to non-scalar type 'pair<[...],vector<int>>' requested
   60 |                 pair<int,vector<int> >cur=q.top();
      |                                           ~~~~~^~
a.cc:62:30: error: no matching function for call to 'std::unordered_map<std::vector<short int>, int>::find(std::vector<int>&)'
   62 |                 if(depth.find(cur.second)!=depth.end())continue;
      |                    ~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:2:
/usr/include/c++/14/bits/unordered_map.h:876:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) [with _Key = std::vector<short int>; _Tp = int; _Hash = std::hash<std::vector<short int> >; _Pred = std::equal_to<std::vector<short int> >; _Alloc = std::allocator<std::pair<const std::vector<short int>, int> >; iterator = std::__detail::_Insert_base<std::vector<short int>, std::pair<const std::vector<short int>, int>, std::allocator<std::pair<const std::vector<short int>, int> >, std::__detail::_Select1st, std::equal_to<std::vector<short int> >, std::hash<std::vector<short int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::iterator; key_type = std::vector<short int>]'
  876 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/unordered_map.h:876:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::unordered_map<std::vector<short int>, int>::key_type&' {aka 'const std::vector<short int>&'}
  876 |       find(const key_type& __x)
      |            ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:887:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::find(const key_type&) const [with _Key = std::vector<short int>; _Tp = int; _Hash = std::hash<std::vector<short int> >; _Pred = std::equal_to<std::vector<short int> >; _Alloc = std::allocator<std::pair<const std::vector<short int>, int> >; const_iterator = std::__detail::_Insert_base<std::vector<short int>, std::pair<const std::vector<short int>, int>, std::allocator<std::pair<const std::vector<short int>, int> >, std::__detail::_Select1st, std::equal_to<std::vector<short int> >, std::hash<std::vector<short int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::const_iterator; key_type = std::vector<short int>]'
  887 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/14/bits/unordered_map.h:887:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::unordered_map<std::vector<short int>, int>::key_type&' {aka 'const std::vector<short int>&'}
  887 |       find(const key_type& __x) const
      |            ~~~~~~~~~~~~~~~~^~~
a.cc:63:22: error: no match for 'operator[]' (operand types are 'std::unordered_map<std::vector<short int>, int>' and 'std::vector<int>')
   63 |                 depth[cur.second]=cur.first;
      |                      ^
/usr/include/c++/14/bits/unordered_map.h:987:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = std::vector<short int>; _Tp = int; _Hash = std::hash<std::vector<short int> >; _Pred = std::equal_to<std::vector<short int> >; _Alloc = std::allocator<std::pair<const std::vector<short int>, int> >; mapped_type = int; key_type = std::vector<short int>]'
  987 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:987:34: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::unordered_map<std::vector<short int>, int>::key_type&' {aka 'const std::vector<short int>&'}
  987 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:991:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&&) [with _Key = std::vector<short int>; _Tp = int; _Hash = std::hash<std::vector<short int> >; _Pred = std::equal_to<std::vector<short int> >; _Alloc = std::allocator<std::pair<const std::vector<short int>, int> >; mapped_type = int; key_type = std::vector<short int>]'
  991 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:991:29: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::unordered_map<std::vector<short int>, int>::key_type&&' {aka 'std::vector<short int>&&'}
  991 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
a.cc:68:31: error: no matching function for call to 'std::priority_queue<std::pair<int, std::vector<short int> > >::push(std::pair<int, std::vector<int> >)'
   68 |                         q.push(make_pair(cur.first-cur.second[i]-cur.second[j],cur.second));
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::vector<short int> >; _Sequence = std::vector<std::pair<int, std::vector<short int> >, std::allocator<std::pair<int, std::vector<short int> > > >; _Compare = std::less<std::pair<int, std::vector<short int> > >; value_type = std::pair<int, std::vector<short int> >]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from 'std::pair<int, std::vector<int> >' to 'const std::priority_queue<std::pair<int, std::vector<short int> > >::value_type&' {aka 'const std::pair<int, std::vector<short int> >&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<int, std::vector<short int> >; _Sequence = std::vector<std::pair<int, std::vector<short int> >, std::allocator<std::pair<int, std::vector<short int> > > >; _Compare = std::less<std::pair<int, std::vector<short int> > >; value_type = std::pair<int, std::vector<short int> >]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from 'std::pair<int, std::vector<int> >' to 'std::priority_queue<std::pair<int, std::vector<short int> > >::value_type&&' {aka 'std::pair<int, std::vector<short int> >&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~