제출 #1149271

#제출 시각아이디문제언어결과실행 시간메모리
1149271duckindog코알라 (JOI13_koala)C++17
20 / 100
2096 ms1864 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 100'000 + 10;
const long long MAX = 2'000'000'000'000'000'000;

int k, m, d, a, n;
int pos[N], add[N];

long long f[N];

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);

  cin >> k >> m >> d >> a >> n;
  for (int i = 1; i <= n; ++i) cin >> pos[i] >> add[i];
  pos[0] = k, pos[n + 1] = m;
   
  fill(f + 1, f + n + 2, -MAX);
  for (int i = 1; i <= n + 1; ++i) { 
    for (int j = 0; j < i; ++j) { 
      f[i] = max(f[i], f[j] - 1ll * ((pos[i] - pos[j] - 1) / d + 1) * a  + add[i]);
    }
  }

  cout << f[n + 1] << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...