제출 #361274

#제출 시각아이디문제언어결과실행 시간메모리
361274Lam_lai_cuoc_doi코알라 (JOI13_koala)C++17
20 / 100
24 ms2028 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
 
const bool typetest = 0;
const ll Inf = 2e18;
const int N = 1e5 + 5;
ll k, m, d, a, b[N], dp[N];
int n;
ll t[N];
 
void Read()
{
    cin >> k >> m >> d >> a >> n;
    for (int i = 1; i <= n; ++i)
        cin >> t[i] >> b[i];
    t[0] = k;
    t[n + 1] = m;
}
 
void Solve()
{
    dp[0] = 0;
  	if(n > 5e3){
		cout << "0";
      return;
    }
    for (int i = 1; i <= n + 1; ++i)
    {
        dp[i] = -Inf;
        for (int j = 0; j < i; ++j)
            dp[i] = max(dp[i], dp[j] - (ll)ceil((ld)(t[i] - t[j]) * 1.0 / d) * a);
        dp[i] += b[i];
    }
    cout << dp[n + 1];
}
 
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t(1);
    if (typetest)
        cin >> t;
    for (int _ = 1; _ <= t; ++_)
    {
        Read();
        Solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...