Submission #140840

#TimeUsernameProblemLanguageResultExecution timeMemory
140840DrumpfTheGodEmperorSemiexpress (JOI17_semiexpress)C++14
100 / 100
993 ms141904 KiB
#include <bits/stdc++.h> #define int long long #define bp __builtin_popcountll #define pb push_back #define in(s) freopen(s, "r", stdin); #define out(s) freopen(s, "w", stdout); #define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\ freopen((string(s) + "." + end2).c_str(), "w", stdout); #define fi first #define se second #define bw(i, r, l) for (int i = r - 1; i >= l; i--) #define fw(i, l, r) for (int i = l; i < r; i++) #define fa(i, x) for (auto i: x) using namespace std; const int mod = 1e9 + 7, inf = 1061109567; const long long infll = 4557430888798830399; const int N = 3005; int n, m, k, a, b, c, t, s[N], mxStations[N][N], dp[N][N]; signed main() { #ifdef BLU in("blu.inp"); #endif ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> k >> a >> b >> c >> t; k -= m; memset(mxStations, 0, sizeof mxStations); fw (i, 0, m) cin >> s[i]; fw (i, 0, m) { int leftBound = s[i], rightBound = n; if (i < m - 1) rightBound = s[i + 1] - 1; //mxStations[i][j]: Maximum stations between the bounds if j stations are used. //Greedily place a station at minimum station that can't be reached. int remainingTime = t - b * (s[i] - 1); if (remainingTime < 0) break; int curPos = 1; fw (j, 0, k + 1) { int remaining = remainingTime - (curPos - 1) * c; if (remaining < 0) break; curPos = min(curPos + remaining / a, rightBound - leftBound + 1); mxStations[i][j] = curPos; curPos++; // cout << "Place station " << j + 1 << " at pos " << leftBound + curPos - 1 << "\n"; // cout << "mxStations[" << i << "][" << j << "] = " << mxStations[i][j] << "\n"; } if (i == 0) { fw (j, 0, k + 1) mxStations[i][j]--; //Not including 1. } } memset(dp, 0, sizeof dp); fw (i, 0, m) fw (j, 0, k + 1) { fw (l, 0, j + 1) { int lst = i ? dp[i - 1][j - l] : 0; dp[i][j] = max(dp[i][j], lst + mxStations[i][l]); } } cout << dp[m - 1][k]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...