Language: C++

#include <iostream>
using namespace std;
#include<vector>

int n, m, x;
int max = 100000000;
int ans[12];
int c[12];
int a[12][12];
int sum;


// 実際に組合せを生成する
// comb: 生成された組合せ配列
// step: n桁目までが生成されていることを示す。
// init: その桁始まりの数を示す。
void makeCombination(vector<int> comb, int n, int r, int step, int init) {
    // r桁すべてが生成された
    if (step == r) {
        //for (int j = 0; j < r; ++j) {
        //    cout << comb[j] << " ";
        //}
        //cout << endl;
        //++cnt;
        bool ok = true;
        sum = 0;
        for (int i = 0; i < m; i++) {
            ans[i] = 0;
        }
        for (int j = 0; j < r; j++) {
            for (int k = 0; k < m; k++) {
                ans[k] += a[comb[j]][k];
            }
            sum += c[comb[j]];
        }
        for (int i = 0; i < m; i++) {
            if (ans[i] < x)ok = false;
        }
        if (ok == true) {
            if (sum < max)max = sum;
        }
        return;
    }

    // 全桁生成されていない
    for (int i = init; i <= n - r + step; ++i) {
        comb.push_back(i);
        makeCombination(comb, n, r, step + 1, i + 1);
        // ここで配列から一つ排除しないと困ったことになる
        comb.pop_back();
    }
}

// makeCombinationに値を渡すためだけの関数
// n個の中からr個選択する
void combination(int n, int r) {
    vector<int> comb;
    makeCombination(comb, n, r, 0, 0);
}

//int main(void) {
//    combination(7, 3);
//    //cout << cnt;
//    return 0;
//}


int main()
{


   
    cin >> n >> m >> x;

    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }

    }

    for (int i = 1; i <= m; i++) {

        combination(n, i);


    }
    if (max == 100000000) {
        cout << -1 << endl;
    }
    else {
        cout << max << endl;
    }



}







Compiler output:
a.cc: In function 'void makeCombination(std::vector<int>, int, int, int, int)':
a.cc:40:23: error: reference to 'max' is ambiguous
   40 |             if (sum < max)max = sum;
      |                       ^~~
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:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:5: note:                 'int max'
    6 | int max = 100000000;
      |     ^~~
a.cc:40:27: error: reference to 'max' is ambiguous
   40 |             if (sum < max)max = sum;
      |                           ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:5: note:                 'int max'
    6 | int max = 100000000;
      |     ^~~
a.cc: In function 'int main()':
a.cc:89:9: error: reference to 'max' is ambiguous
   89 |     if (max == 100000000) {
      |         ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:5: note:                 'int max'
    6 | int max = 100000000;
      |     ^~~
a.cc:93:17: error: reference to 'max' is ambiguous
   93 |         cout << max << endl;
      |                 ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:5: note:                 'int max'
    6 | int max = 100000000;
      |     ^~~