Submission #810256

# Submission time Handle Problem Language Result Execution time Memory
810256 2023-08-06T07:40:31 Z vjudge1 코알라 (JOI13_koala) C++17
20 / 100
2000 ms 3800 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;
    b[1] = 0;
    b[n] = 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 = 1LL * times * cost;
            dp[i] = max(dp[i], dp[j] - total_cost + b[i]);
        }
    }
    cout << dp[n];
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1108 KB Output is correct
2 Correct 3 ms 1108 KB Output is correct
3 Correct 3 ms 1108 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 4 ms 1108 KB Output is correct
6 Correct 3 ms 1108 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 5 ms 1108 KB Output is correct
9 Correct 3 ms 1108 KB Output is correct
10 Correct 3 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2064 ms 3800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2067 ms 3796 KB Time limit exceeded
2 Halted 0 ms 0 KB -