| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 217403 | Just_Solve_The_Problem | 코알라 (JOI13_koala) | C++11 | 8 ms | 384 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = (int)1e5 + 7;
int k, m, d, a, n;
int t[N], b[N];
ll dp[N];
ll get(int i, int j) {
  int dis = t[j] - t[i];
  return -(dis + d - 1) / d * 1ll * a;
}
main() {
  scanf("%d %d %d %d %d", &k, &m, &d, &a, &n);
  if (n > 1000) {
    return 0;
  }
  t[0] = k;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &t[i], &b[i]);
  }
  t[n + 1] = m;
  for (int i = 1; i <= n + 1; i++) {
    dp[i] = -1e18;
    for (int j = 0; j < i; j++) {
      dp[i] = max(dp[i], dp[j] + b[i] - get(j, i));
    }
  }
  cout << dp[n + 1];
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
