Language: C++

#include <iostream>
#include <vector>

using namespace std;

int N, A, B, C;
vector<int> l;

int min = 99999;

void calc(vector<int> v) {
    int a = 0, b = 0, c = 0, dupe = 0;
    for (int i = 0; i < N; i++) {
        if (v[i] == 0) {
            if (a != 0) dupe += 10;
            a += l[i];
        }
        if (v[i] == 1) {
            if (b != 0) dupe += 10;
            b += l[i];
        }
        if (v[i] == 2) {
            if (c != 0) dupe += 10;
            c += l[i];
        }
    }
    const int sum = abs(a - A) + abs(b - B) + abs(c - C) + dupe;
    if (a == 0 || b == 0 || c == 0) return;
    if (sum < min) {
        min = sum;
        for (int i = 0; i < N; i++) {
            cout << v[i] << " ";
        }
        cout << sum << endl;
    }
    
    return;
}

void dfs(int cur, vector<int> v) {
    if (cur == N) {
        calc(v);
        return;
    }
    for (int i = 0; i < 4; i++) {
        v[cur] = i;
        dfs(cur + 1, v);
    }
    return;
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    dfs(0, vector<int>(N));

	cout << min << endl;

    return 0;
}

Compiler output:
a.cc: In function 'void calc(std::vector<int>)':
a.cc:29:15: error: reference to 'min' is ambiguous
   29 |     if (sum < min) {
      |               ^~~
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:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:9:5: note:                 'int min'
    9 | int min = 99999;
      |     ^~~
a.cc:30:9: error: reference to 'min' is ambiguous
   30 |         min = sum;
      |         ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:9:5: note:                 'int min'
    9 | int min = 99999;
      |     ^~~
a.cc: In function 'int main()':
a.cc:61:17: error: reference to 'min' is ambiguous
   61 |         cout << min << endl;
      |                 ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:9:5: note:                 'int min'
    9 | int min = 99999;
      |     ^~~