# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422103 | tengiz05 | Semiexpress (JOI17_semiexpress) | C++17 | 14 ms | 4548 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n, m, k, A, B, C, T;
std::cin >> n >> m >> k;
std::cin >> A >> B >> C >> T;
std::vector<i64> a(m);
for (int i = 0; i < m; i++) {
std::cin >> a[i];
a[i]--;
}
i64 ans = -1;
std::vector<i64> seg;
for (int i = 0; i < m - 1; i++) {
i64 l = a[i];
for (int j = 0; j <= k - m; j++) {
if (l == a[i + 1] || B * a[i] + C * (l - a[i]) > T) {
break;
}
i64 left = T - B * a[i] - C * (l - a[i]);
i64 r = std::min(a[i + 1], l + left / A + 1);
if (l == a[i]) {
ans += r - l;
} else {
seg.push_back(r - l);
}
l = r;
}
}
ans += B * a[m - 1] <= T;
sort(seg.rbegin(), seg.rend());
for (int i = 0; i < k - m && i < seg.size(); i++) {
ans += seg[i];
}
std::cout << ans << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |