Submission #654295

#TimeUsernameProblemLanguageResultExecution timeMemory
654295lunchbox1Semiexpress (JOI17_semiexpress)C++17
100 / 100
1 ms340 KiB
/* Semiexpress https://oj.uz/problem/view/JOI17_semiexpress */ #include <bits/stdc++.h> using namespace std; typedef long long LL; int main() { ios::sync_with_stdio(0), cin.tie(0); int n, m, k; cin >> n >> m >> k; LL a, b, c; cin >> a >> b >> c; long long t; cin >> t; vector<LL> s(m), p(m - 1); for (LL& x : s) cin >> x; priority_queue<pair<LL, int>> pq; LL ans = b * (n - 1) <= t ? 0 : -1; for (int i = 0; i < m - 1; i++) { if (b * (s[i] - 1) > t) continue; LL u = min(s[i + 1] - 1, s[i] + (t - b * (s[i] - 1)) / a); ans += u - s[i] + 1; p[i] = u + 1; if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t) pq.push({min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a) - p[i] + 1, i}); } for (int it = 0; it < k - m; it++) { if (pq.empty()) break; auto [v, i] = pq.top(); pq.pop(); ans += v, p[i] += v; if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t) pq.push({min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a) - p[i] + 1, i}); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...