Submission #654286

#TimeUsernameProblemLanguageResultExecution timeMemory
654286FarbodSemiexpress (JOI17_semiexpress)C++17
100 / 100
2 ms340 KiB
/* * In the name of God * * Author: Farbod Doost * Last Modified: Mon, 31 Oct 2022 (00:36:55) * */ #include <iostream> #include <set> using namespace std; const int N = 3005; int n, m, k, s[N]; long long a, b, c, T; long long ans = 0; set <pair <int, pair <int, int>>> st; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> k >> a >> b >> c >> T; for (int i = 0; i < m; i++) cin >> s[i]; s[m] = n + 1; for (int i = 0; i < m; i++) { long long tmp = b * (s[i] - 1); if (tmp > T) break; long long x = (T - tmp) / a; x = min(x, 1LL * s[i + 1] - s[i] - 1); ans += x + 1; if (s[i] + x + 1 != s[i + 1]) { tmp += (x + 1) * c; if (tmp <= T) { long long y = (T - tmp) / a; y = min(y, s[i + 1] - s[i] - x - 2); st.insert({-(y + 1), {i, s[i] + x + y + 2}}); } } } for (int it = 0; it < k - m && st.size(); it++) { int i = st.begin() -> second.first; long long x = st.begin() -> second.second; ans -= (st.begin() -> first); st.erase(st.begin()); long long tmp = b * (s[i] - 1) + (x - s[i]) * c; if (tmp <= T && x != s[i + 1]) { long long y = (T - tmp) / a; y = min(y, 1LL * s[i + 1] - x - 1); st.insert({-(y + 1), {i, x + y + 1}}); } } cout << ans - 1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...