Submission #307547

#TimeUsernameProblemLanguageResultExecution timeMemory
307547TeaTimeSemiexpress (JOI17_semiexpress)C++17
48 / 100
38 ms32504 KiB
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <set> #include <map> #include <queue> #include <random> #include <chrono> #include <tuple> #include <random> #include <cmath> using namespace std; typedef long long ll; typedef long double ld; #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10; vector<ll> vec; ll dpAns[10000][2], dpt[SIZE], good[SIZE]; ll n, m, k, a, b, c; void add(int curInd, int us, int s) { for (int i = k; i >= 0; i--) { if (i - us >= 0) { dpAns[i][curInd] = max(dpAns[i][curInd], dpAns[i - us][!curInd] + s); } } } int main() { fastInp; cin >> n >> m >> k; cin >> a >> b >> c; ll t; cin >> t; vec.resize(m); for (auto &cur : vec) cin >> cur; good[1] = 1; ll lastI = -1, curInd = 0; for (int i = 1; i <= n; i++) { dpt[i] = dpt[i - 1] + a; if (vec[lastI + 1] == i) { good[i] = 1; if (i == 1) { dpt[i] = 0; lastI++; continue; } dpt[i] = min(dpt[i], min(dpt[vec[lastI]] + c * (i - vec[lastI]), dpt[vec[lastI]] + b * (i - vec[lastI]))); lastI++; } } k -= m; ll ans = 0, added = 0, lastPos = 1, s = 0; for (int i = 1; i <= n; i++) { if (dpt[i] <= t) { ans++; } else { s++; } dpt[i] = min(dpt[i], dpt[i - 1] + a); if (dpt[i] > t) { added++; dpt[i] = dpt[lastPos] + c * (i - lastPos); lastPos = i; } if (dpt[i] <= t) { add(curInd, added, s); } if (good[i]) { lastPos = i; curInd = !curInd; for (int j = 0; j <= k; j++) dpAns[j][curInd] = dpAns[j][!curInd]; s = 0; added = 0; } } s = 0; for (int i = 0; i <= k; i++) s = max(s, dpAns[i][curInd]); cout << ans + s - 1; return 0; } /* 10 3 5 10 3 5 30 1 6 10 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...