Problem p02683 (C++) — buggy submission, verdict: Runtime Error

// Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define pb push_back
#define ss second
#define ll long long
#define MAX 5000
#define mpi map<int, int>
#define mpll map<ll, ll>
#define pll pair<ll, ll>
#define plld pair<ll, double>
#define SKILLER                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define vi std::vector<int>
#define vll std::vector<ll>
#define vs std::vector<string>
#define vvi std::vector<std::vector<int>>
#define vvll std::vector<std::vector<ll>>
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define loop(i, a, b) for (int i = a; i < b; i++)
#define debug(x)                                                               \\
  cout << x << " "                                                             \\
       << "\\n";
#define debug1(x, y) cout << x << " " << y << "\\n";
#define debug2(x, y, z) cout << x << " " << y << " " << z << "\\n";
#define int ll
const int N = 1e6 + 5, Mod = 1e9 + 7;
int32_t main() {
  SKILLER;

  int n, m, x1;
  cin >> n >> m >> x1;
  std::vector<std::vector<int>> v(n, vector<int>(m));
  std::vector<int> cst(n);
  for (int i = 0; i < n; i++) {
    cin >> cst[i];
    for (int j = 0; j < m; j++) {
      // int x; cin >> x;
      cin >> v[i][j];
    }
  }
  int l = (1LL << (n));
  int mn = 1e16;
  for (int i = 1; i < l; i++) {
    int ansr = 0;
    std::vector<int> temp(m, 0);
    int x = i;
    int j = 0;
    while (x) {
      if (x & 1) {
        ansr += cst[j];
        // cout << v[j][0]<<"\\n";
        for (int k = 0; k < m; k++)
          temp[k] += v[j][k];
      }
      j++;
      x = x >> 1;
    }
    int flag = 1;
    for (int k = 0; k < m; k++) {
      if (temp[k] < x1)
        flag = 0;
    }
    if (flag) {
      mn = min(mn, ansr);
    }
  }
  if (mn >= 1e15)
    cout << "-1";
  else
    cout << mn;
  return 0;
}

Error: WA

Fixed submission:

// Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define pb push_back
#define ss second
#define ll long long
#define MAX 5000
#define mpi map<int, int>
#define mpll map<ll, ll>
#define pll pair<ll, ll>
#define plld pair<ll, double>
#define SKILLER                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define vi std::vector<int>
#define vll std::vector<ll>
#define vs std::vector<string>
#define vvi std::vector<std::vector<int>>
#define vvll std::vector<std::vector<ll>>
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define loop(i, a, b) for (int i = a; i < b; i++)
#define debug(x)                                                               \\
  cout << x << " "                                                             \\
       << "\\n";
#define debug1(x, y) cout << x << " " << y << "\\n";
#define debug2(x, y, z) cout << x << " " << y << " " << z << "\\n";
#define int ll
const int N = 1e6 + 5, Mod = 1e9 + 7;
int32_t main() {
  SKILLER;

  int n, m, x1;
  cin >> n >> m >> x1;
  vector<int> v[n], cst(n);
  for (int i = 0; i < n; i++) {
    cin >> cst[i];
    for (int j = 0; j < m; j++) {
      int x;
      cin >> x;
      v[i].pb(x);
    }
  }
  int l = (1LL << (n + 1)) - 1;
  int mn = 1e18;
  for (int i = 1; i <= l; i++) {
    int ansr = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    int x = i;
    int j = 0;
    while (x) {
      if (x & 1) {
        ansr += cst[j];
        // cout << v[j][0]<<"\\n";
        a += v[j][0];
        b += v[j][1];
        c += v[j][2];
      }
      j++;
      x = x >> 1;
    }

    // cout << a << b << c;
    if (a >= x1 && b >= x1 && c >= x1) {
      if (mn > ansr) {
        mn = ansr;
      }
    }
  }
  if (mn >= 1e5)
    cout << "-1";
  else
    cout << mn;
  return 0;
}