Submission #808701

# Submission time Handle Problem Language Result Execution time Memory
808701 2023-08-05T09:36:49 Z vjudge1 코알라 (JOI13_koala) C++17
0 / 100
2000 ms 1884 KB
#include <bits/stdc++.h>
#define ll long long
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(i) ((1LL) << (i))

using namespace std;
const ll inf = 1e18+7;
const long mod = 1e9+7;
const long Nmax = 1e5+7;

int fr, to, d, cost, n;
ll dp[Nmax], st[4 * Nmax];
int t[Nmax], b[Nmax];
void update(int id, int l, int r, int i, int v)
{
    if (l > i || r < i) return;
    if (l == r)
    {
        st[id] = v;
        return;
    }
    int mid = (l + r) >> 1;
    update(id * 2, l, mid, i, v);
    update(id * 2 + 1, mid + 1, r, i, v);
    st[id] = max(st[id * 2], st[id * 2 + 1]);
}
ll get_max(int id, int l, int r, int u, int v)
{
    if (l > v || r < u) return -inf;
    if (l >= u && r <= v) return st[id];
    int mid = (l + r) >> 1;
    return max(get_max(id * 2, l, mid, u, v), get_max(id * 2 + 1, mid + 1, r, u, v));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("name.inp","r",stdin);
    //freopen("name.out","w",stdout);
    cin >> fr >> to >> d >> cost >> n;
    t[n + 2] = to;
    t[1] = fr;
    for (int i = 2; i <= n + 1; i++) cin >> t[i] >> b[i];
    n += 2;
    memset(dp, -0x3f, sizeof dp);
    dp[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        for (int j = 1; j < i; j++)
        {
            int dis = t[i] - t[j];
            int times = dis / d;
            if (dis % d != 0) times++;
            ll total_cost = times * cost;
            dp[i] = max(dp[i], dp[j] - total_cost + b[i]);
        }
    }
    cout << dp[n];
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2060 ms 1884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 ms 1792 KB Time limit exceeded
2 Halted 0 ms 0 KB -