Submission #876430

#TimeUsernameProblemLanguageResultExecution timeMemory
876430ArashJafariyanSemiexpress (JOI17_semiexpress)C++17
100 / 100
373 ms55512 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...