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

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define REP(i, k, n) for (int i = k; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define each(it, v)                                                            \\
  for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define INF 1 << 30
#define EPS 1e-8
#define mp make_pair
#define equals(a, b) fabs((a) - (b)) < EPS

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n, k, l;
  double t, u, v;
  cin >> n >> k >> t >> u >> v >> l;

  bool d[100005];
  memset(d, 0, sizeof(d));

  rep(i, n) {
    int x;
    cin >> x;
    d[x] = true;
  }

  double ans = 0;
  double time = 0.0;
  int cnt = 0;

  rep(i, l) {
    if (d[i]) {
      if (cnt == k)
        time = t;
      else
        cnt++;
    }

    if (equals(time, 0.0)) {
      if (cnt > 0) {
        time = t;
        cnt--;
      }
    }

    if (time > EPS) {
      ans += 1.0 / v;
      time -= 1.0 / v;
    } else {
      ans += 1.0 / u;
    }
  }

  cout << fixed;
  cout.precision(20);
  cout << ans << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define REP(i, k, n) for (int i = k; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define each(it, v)                                                            \\
  for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define INF 1 << 30
#define EPS 1e-8
#define mp make_pair
#define equals(a, b) fabs((a) - (b)) < EPS

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, double>, pair<double, int>> state;

int main() {
  int n, k, l;
  double t, u, v;
  cin >> n >> k >> t >> u >> v >> l;

  bool d[100005];
  memset(d, 0, sizeof(d));

  rep(i, n) {
    int x;
    cin >> x;
    d[x] = true;
  }

  // ??????i, ????????§?????????t, ????????????T, ?????£???????????????
  queue<state> que;
  que.push(mp(mp(0, 0), mp(0, 0)));

  map<state, bool> memo;

  double ans = INF;

  while (que.size()) {
    state s = que.front();
    que.pop();
    int cur = s.first.first;
    double res = s.first.second;
    double time = s.second.first;
    int cnt = s.second.second;

    if (cur >= l) {
      ans = min(ans, res);
      continue;
    }

    if (d[cur]) {
      cnt = min(k, cnt + 1);
    }

    if (equals(time, 0.0)) {
      if (cnt > 0) {
        cnt--;
        time = t;
      }
    }

    if (time > EPS) {
      state next = mp(mp(cur + 1, res + (1.0 / v)), mp(time - (1.0 / v), cnt));

      if (!memo[next]) {
        memo[next] = true;
        que.push(next);
      }

      if (cnt > 0) {
        state next2 = mp(mp(cur + 1, res + (1.0 / v)), mp(t, cnt - 1));
        if (!memo[next2]) {
          memo[next2] = true;
          que.push(next2);
        }
      }
    } else {
      state next = mp(mp(cur + 1, res + (1.0 / u)), mp(0.0, cnt));

      if (!memo[next]) {
        memo[next] = true;
        que.push(next);
      }
    }
  }

  cout << fixed;
  cout.precision(10);
  cout << ans << endl;

  return 0;
}