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>
using namespace std;
#define ll long long
#define pb push_back
const int M = 3e3 + 4;
int n, m, k, a, b, c, s[M];
ll t, mx[M][M], dp[M][M];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
cin >> a >> b >> c;
cin >> t;
for (int i = 0; i < m; ++i) {
cin >> s[i];
--s[i];
}
k -= m; // k: number of semi-express stations we need to add
s[m] = n;
// mx[i][j]: maximum distance to travel from station s[i] if we use exactly j semi-express station
// dp[i][j]: maximum answer if we use i stations from s and j semi-express station
for (int i = 0; i < m; ++i) {
ll preCost = 1ll * s[i] * b;
if (preCost > t)
break;
mx[i][0] = (t - preCost) / a;
mx[i][0] = min(mx[i][0], 0ll + s[i + 1] - s[i] - 1);
for (int j = 1; j <= k; ++j) {
if (mx[i][j - 1] == s[i + 1] - s[i] - 1) {
mx[i][j] = mx[i][j - 1];
break;
}
preCost = 1ll * s[i] * b + 1ll * c * (mx[i][j - 1] + 1);
if (preCost > t) {
mx[i][j] = mx[i][j - 1];
break;
}
ll canTravel = (t - preCost) / a;
mx[i][j] = mx[i][j - 1] + 1 + canTravel;
mx[i][j] = min(mx[i][j], 0ll + s[i + 1] - s[i] - 1);
}
if (i == 0)
for (int j = 0; j <= k; ++j)
dp[i][j] = mx[i][j];
else
for (int j = 0; j <= k; ++j)
for (int l = 0; l <= j; ++l)
dp[i][j] = max(dp[i][j], dp[i - 1][j - l] + mx[i][l] + 1);
}
ll ans = 0;
for (int i = 0; i < m; ++i)
for (int j = 0; j <= k; ++j)
ans = max(ans, dp[i][j]);
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |