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

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define EL '\\n'
#define print(i) std::cout << (i) << '\\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO {
  FIO() {
    std::cin.tie(0);
    std::cout.tie(0);
    std::ios_base::sync_with_stdio(0);
    std::cout << std::fixed << std::setprecision(15);
  }
} fIO;
/*-*/

template <typename T> std::vector<int> sort_indexes(const std::vector<T> &v) {
  std::vector<int> idx(v.size());
  std::iota(idx.begin(), idx.end(), 0);
  std::sort(idx.begin(), idx.end(),
            [&v](int i1, int i2) { return v[i1] < v[i2]; });
  return idx;
}

int main() {
  int d;
  std::cin >> d;
  int N = 26;
  std::vector<lnt> c(N);
  std::vector<std::vector<lnt>> v(d, std::vector<lnt>(N));
  rep(i, N) std::cin >> c[i];
  rep(i, d) {
    rep(j, N) { std::cin >> v[i][j]; }
  }
  std::vector<int> last(N, -1);
  rep(i, d) {
    std::vector<int> idx(N);
    std::iota(idx.begin(), idx.end(), 0);
    double X = 1;
    double Y = 3;
    auto f = [&](int ix) -> double {
      return c[ix] * (i - last[ix] + X) + Y * v[i][ix];
    };
    std::sort(idx.begin(), idx.end(),
              [&](int i1, int i2) { return f(i1) > f(i2); });
    last[idx[0]] = i;
    print(idx[0] + 1);
  }
  /*
  lnt sum=0;
  std::vector<int> last(N,-1);
  rep(i,d) {
          int t;
          std::cin >> t;
          t--;
          sum+=v[i][t];
          last[t]=i;
          rep(j,N) sum-=(i-last[j])*c[j];
          print(sum);
  }
  */
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define EL '\\n'
#define print(i) std::cout << (i) << '\\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO {
  FIO() {
    std::cin.tie(0);
    std::cout.tie(0);
    std::ios_base::sync_with_stdio(0);
    std::cout << std::fixed << std::setprecision(15);
  }
} fIO;
/*-*/

template <typename T> std::vector<int> sort_indexes(const std::vector<T> &v) {
  std::vector<int> idx(v.size());
  std::iota(idx.begin(), idx.end(), 0);
  std::sort(idx.begin(), idx.end(),
            [&v](int i1, int i2) { return v[i1] < v[i2]; });
  return idx;
}

int main() {
  int d;
  std::cin >> d;
  int N = 26;
  std::vector<lnt> c(N);
  std::vector<std::vector<lnt>> v(d, std::vector<lnt>(N));
  rep(i, N) std::cin >> c[i];
  rep(i, d) {
    rep(j, N) { std::cin >> v[i][j]; }
  }
  std::vector<std::vector<int>> sorted(d);
  std::vector<int> last(N, -1);
  rep(i, d) {
    std::vector<int> idx(N);
    std::iota(idx.begin(), idx.end(), 0);
    int X = 1;
    int Y = 3;
    std::sort(idx.begin(), idx.end(), [&](int i1, int i2) {
      return c[i1] * (i - last[i1] + X) + Y * v[i][i1] >
             c[i2] * (i - last[i1] + X) + Y * v[i][i2];
    });
    last[idx[0]] = i;
    print(idx[0] + 1);
  }
  /*
  lnt sum=0;
  std::vector<int> last(N,-1);
  rep(i,d) {
          int t;
          std::cin >> t;
          t--;
          sum+=v[i][t];
          last[t]=i;
          rep(j,N) sum-=(i-last[j])*c[j];
          print(sum);
  }
  */
}