Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")
#define ret return 0

int n, a, b, c;

int search(int used, int a_, int b_, int c_,vector<int> v)
{
	if (used == n)
	{
		if (min(min(a,b),c) > 0)
			return (abs(a - a_) + abs(b - b_) + abs(c - c_) - 30);
		else
			return INF;
	}
	int ans1 = search(used + 1, a_, b_, c_);
	int ans2 = search(used + 1, a_ + v[used], b_, c_)+10;
	int ans3 = search(used + 1, a_, b_ + v[used], c_)+10;
	int ans4 = search(used + 1, a_, b_, c_ + v[used])+10;

	return min(min(ans1,ans2),min(ans3,ans4));
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> a >> b >> c;

	vector<int> l(n);

	rep(i, n)
	{
		cin >> l[i];
	}

	int ans = search(0, 0, 0, 0,l);
	cout << ans << endl;

	ret;
}

Compiler output:
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = int; _Predicate = __gnu_cxx::__ops::_Iter_equals_iter<int>]':
/usr/include/c++/14/bits/stl_algobase.h:2203:23:   required from '_ForwardIterator1 std::__search(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _BinaryPredicate) [with _ForwardIterator1 = int; _ForwardIterator2 = int; _BinaryPredicate = __gnu_cxx::__ops::_Iter_equal_to_iter]'
 2203 |         return std::__find_if(__first1, __last1,
      |                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
 2204 |                 __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4102:27:   required from '_FIter1 std::search(_FIter1, _FIter1, _FIter2, _FIter2) [with _FIter1 = int; _FIter2 = int]'
 4102 |       return std::__search(__first1, __last1, __first2, __last2,
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4103 |                            __gnu_cxx::__ops::__iter_equal_to_iter());
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:39:19:   required from here
   39 |         int ans1 = search(used + 1, a_, b_, c_);
      |                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:2153:48: error: no matching function for call to '__iterator_category(int&)'
 2153 |                        std::__iterator_category(__first));
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66,
                 from /usr/include/c++/14/string:47:
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/14/bits/stl_algobase.h:2153:34:   required from '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = int; _Predicate = __gnu_cxx::__ops::_Iter_equals_iter<int>]'
 2153 |                        std::__iterator_category(__first));
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:2203:23:   required from '_ForwardIterator1 std::__search(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _BinaryPredicate) [with _ForwardIterator1 = int; _ForwardIterator2 = int; _BinaryPredicate = __gnu_cxx::__ops::_Iter_equal_to_iter]'
 2203 |         return std::__find_if(__first1, __last1,
      |                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
 2204 |                 __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4102:27:   required from '_FIter1 std::search(_FIter1, _FIter1, _FIter2, _FIter2) [with _FIter1 = int; _FIter2 = int]'
 4102 |       return std::__search(__first1, __last1, __first2, __last2,
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4103 |                            __gnu_cxx::__ops::__iter_equal_to_iter());
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:39:19:   required from here
   39 |         int ans1 = search(used + 1, a_, b_, c_);
      |                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:71:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_equal_to_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]':
/usr/include/c++/14/bits/stl_algobase.h:2223:22:   required from '_ForwardIterator1 std::__search(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _BinaryPredicate) [with _ForwardIterator1 = int; _ForwardIterator2 = int; _BinaryPredicate = __gnu_cxx::__ops::_Iter_equal_to_iter]'
 2223 |           while (__predicate(__current, __p))
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4102:27:   required from '_FIter1 std::search(_FIter1, _FIter1, _FIter2, _FIter2) [with _FIter1 = int; _FIter2 = int]'
 4102 |       return std::__search(__first1, __last1, __first2, __last2,
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4103 |                            __gnu_cxx::__ops::__iter_equal_to_iter());
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:39:19:   required from here
   39 |         int ans1 = search(used + 1, a_, b_, c_);
      |                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:117:16: error: invalid type argument of unary '*' (have 'int')
  117 |       { return *__it1 == *__it2; }
      |                ^~~~~~
/usr/include/c++/14/bits/predefined_ops.h:117:26: error: invalid type argument of unary '*' (have 'int')
  117 |       { return *__it1 == *__it2; }
      |                          ^~~~~~