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

#include "algorithm"
#include "bitset"
#include "cassert"
#include "climits"
#include "cmath"
#include "cstdio"
#include "ctime"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main() {
  ll D;
  cin >> D;

  vector<ll> c(26);
  ll sum_c = 0;
  rep(0, i, 26) {
    cin >> c.at(i);
    sum_c += c.at(i);
  }

  vector<vector<ll>> s(D, vector<ll>(26, 0));
  rep(0, i, D) {
    rep(0, j, 26) { cin >> s.at(i).at(j); }
  }

  ll score = 0, dec = 0; // i日目のスコア、スコアの減少量
  vector<ll> t(D), last(26, 0), ans(D, 0);
  rep(0, i, D) {
    // 今日開くコンテストと得られる満足度
    ll today_i = 0, today_score = 0;
    // i日目に各コンテストを開催したと仮定して満足度を求める
    rep(0, j, 26) {
      ll sum = s.at(i).at(j);
      sum = sum - (dec + sum_c - (c.at(j) * (last.at(j) + 1)));
      if (score + today_score < score + sum) {
        today_i = j;
        today_score = sum;
      }
    }

    // ループが終了したら今日開くコンテストが決まるので、last(d,i)を更新する
    rep(0, j, 26) { last.at(j) += 1; }
    last.at(today_i) = 0;

    // decの更新
    dec = 0;
    rep(0, j, 26) { dec += c.at(j) * last.at(j); }

    // scoreの更新
    score += today_score;

    // 答え
    t.at(i) = today_i + 1;
    ans.at(i) = score;
  }

  rep(0, i, D) { cout << t.at(i) << endl; }
}

Error: 0

Fixed submission:

#include "algorithm"
#include "bitset"
#include "cassert"
#include "climits"
#include "cmath"
#include "cstdio"
#include "ctime"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main() {
  ll D;
  cin >> D;

  vector<ll> c(26);
  ll sum_c = 0;
  rep(0, i, 26) {
    cin >> c.at(i);
    sum_c += c.at(i);
  }

  vector<vector<ll>> s(D, vector<ll>(26, 0));
  rep(0, i, D) {
    rep(0, j, 26) { cin >> s.at(i).at(j); }
  }

  ll score = 0, dec = 0; // i日目のスコア、スコアの減少量
  vector<ll> t(D), last(26, 0), ans(D, 0);
  rep(0, i, D) {
    // 今日開くコンテストと得られる満足度
    ll today_i = 0, today_score = 0;
    // i日目に各コンテストを開催したと仮定して満足度を求める
    rep(0, j, 26) {
      ll sum = s.at(i).at(j);
      sum = sum - (dec + sum_c - (c.at(j) * (last.at(i) + 1)));
      if (score + today_score < score + sum) {
        today_i = j;
        today_score = sum;
      }
    }

    // ループが終了したら今日開くコンテストが決まるので、last(d,i)を更新する
    rep(0, j, 26) { last.at(j) += 1; }
    last.at(today_i) = 0;

    // decの更新
    dec = 0;
    rep(0, j, 26) { dec += c.at(j) * last.at(j); }

    // scoreの更新
    score += today_score;

    // 答え
    t.at(i) = today_i + 1;
    ans.at(i) = score;
  }

  rep(0, i, D) { cout << t.at(i) << endl; }
}