Submission #810256

#TimeUsernameProblemLanguageResultExecution timeMemory
810256vjudge1코알라 (JOI13_koala)C++17
20 / 100
2067 ms3800 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...