# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
814350 | vjudge1 | 코알라 (JOI13_koala) | C++17 | 2061 ms | 19404 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define MASK(i) (1 << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define fi first
#define se second
#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define nl cout << "\n"
#define ___ << " " <<
#define mem(a, b) memset((a), (b), sizeof((a)))
#define all(c) (c).begin(), (c).end()
#define Times cerr << "\nTime run: " << clock() / 1000.0 << " ms\n"
#define file "G:\\My Drive\\TIN HOC\\hoang"
using namespace std;
template<class T1, class T2> void mini(T1 &a, T2 b) {if (a > b) a = b;}
template<class T1, class T2> void maxi(T1 &a, T2 b) {if (a < b) a = b;}
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
const int N = 2e6 + 5;
const int LOG = 20;
ll k, m, d, a, n;
ll t[N], b[N];
ll dp[N];
void inp()
{
cin >> k >> m >> d >> a >> n;
for (int i = 1; i <= n; i++)
cin >> t[i] >> b[i];
}
void solve()
{
//fi = max{fj }
mem(dp, -0x3f);
dp[0] = 0;
t[0] = k;
t[n + 1] = m;
for (int i = 1; i <= n + 1; i++)
{
for (int j = 0; j < i; j++)
{
ll lost = dp[j] - ((t[i] - t[j] + d - 1) / d) * a;
maxi(dp[i], lost);
}
dp[i] += b[i];
}
cout << dp[n + 1];
}
void run_with_file()
{
if (fopen(file".inp", "r"))
{
freopen(file".inp", "r", stdin);
freopen(file".out", "w", stdout);
}
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
run_with_file();
int test_case = 1;
//cin >> test_case;
while (test_case--)
{
inp();
solve();
}
Times;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |