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

#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int d;
  cin >> d;
  vector<int> c26(26);
  vector<vector<int>> si(d, vector<int>(26));
  for (int i = 0; i < 26; ++i)
    cin >> c26[i];
  for (int i = 0; i < d; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> si[i][j];

  vector<vector<int>> koho(d);
  for (int i = 0; i < 26; ++i) {
    int hindo;
    if (c26[i] <= 10)
      hindo = 50;
    else if (c26[i] <= 20)
      hindo = 20;
    else if (c26[i] <= 40)
      hindo = 15;
    else if (c26[i] <= 60)
      hindo = 10;
    else
      hindo = 5;

    int j = 0;
    while (j < d - 1) {
      int cnt = 0;
      int mxday = min(j + hindo, d - 1);
      for (int k = mxday; k > j; --k) {
        if (si[k][i] >= 16000) {
          koho[k].push_back(i);
          ++cnt;
          for (int l = j + 1; l <= k; ++l) {
            si[l][i] += (l - j) * (l - j) * c26[i];
          }
          j = k;
          break;
        }
      }
      if (cnt == 0) {
        for (int l = j + 1; l <= mxday; ++l) {
          si[l][i] += (l - j) * (l - j) * c26[i];
        }
        if (mxday != d - 1)
          koho[mxday].push_back(i);
        j = mxday;
      }
    }
  }

  vector<int> ans(d);
  for (int i = 0; i < d; ++i) {
    vector<P> koho2(0);
    if (koho[i].size() == 0) {
      for (int j = 0; j < 26; ++j) {
        koho2.push_back(make_pair(si[i][j], j));
      }
    } else {
      for (int n : koho[i]) {
        koho2.push_back(make_pair(si[i][n], n));
      }
    }
    sort(koho2.begin(), koho2.end());
    reverse(koho2.begin(), koho2.end());
    ans[i] = koho2[0].second;
  }
  for (int i = 0; i < d; ++i) {
    cout << ans[i] + 1 << endl;
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int d;
  cin >> d;
  vector<int> c26(26);
  vector<vector<int>> si(d, vector<int>(26));
  for (int i = 0; i < 26; ++i)
    cin >> c26[i];
  for (int i = 0; i < d; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> si[i][j];

  vector<vector<int>> koho(d);
  for (int i = 0; i < 26; ++i) {
    int hindo;
    if (c26[i] <= 50)
      hindo = (int)(500 / c26[i]);
    else
      hindo = 7;

    int j = 0;
    while (j < d - 1) {
      int cnt = 0;
      int mxday = min(j + hindo, d - 1);
      for (int k = mxday; k > j; --k) {
        if (si[k][i] >= 16000) {
          koho[k].push_back(i);
          ++cnt;
          for (int l = j + 1; l <= k; ++l) {
            si[l][i] += (l - j) * (l - j) * c26[i];
          }
          j = k;
          break;
        }
      }
      if (cnt == 0) {
        for (int l = j + 1; l <= mxday; ++l) {
          si[l][i] += (l - j) * (l - j) * c26[i];
        }
        if (mxday != d - 1)
          koho[mxday].push_back(i);
        j = mxday;
      }
    }
  }

  vector<int> ans(d);
  for (int i = 0; i < d; ++i) {
    vector<P> koho2(0);
    if (koho[i].size() == 0) {
      for (int j = 0; j < 26; ++j) {
        koho2.push_back(make_pair(si[i][j], j));
      }
    } else {
      for (int n : koho[i]) {
        koho2.push_back(make_pair(si[i][n], n));
      }
    }
    sort(koho2.begin(), koho2.end());
    reverse(koho2.begin(), koho2.end());
    ans[i] = koho2[0].second;
  }
  for (int i = 0; i < d; ++i) {
    cout << ans[i] + 1 << endl;
  }
}