# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705295 | rainboy | Semiexpress (JOI17_semiexpress) | C11 | 1 ms | 300 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 <stdio.h>
#define N 3000
long long min(long long a, long long b) { return a < b ? a : b; }
int xx[N + 1], n, k_, k, ans; long long a, b, c, t;
int solve(int d) {
int x, x_, i;
ans = 0, k = 0;
for (i = 0; i < n && xx[i] * a <= t; i++) {
x = min(xx[i] + (t - xx[i] * a) / c + 1, xx[i + 1]);
while (x < xx[i + 1] && xx[i] * a + (x - xx[i]) * b <= t) {
x_ = min(x + (t - xx[i] * a - (x - xx[i]) * b) / c + 1, xx[i + 1]);
if (x_ - x <= d)
break;
x = x_;
if (++k > k_)
return 0;
}
ans += x - xx[i];
}
return 1;
}
int main() {
int i, lower, upper;
scanf("%*d%d%d%lld%lld%lld%lld", &n, &k_, &c, &a, &b, &t), k_ -= n;
for (i = 0; i < n; i++)
scanf("%d", &xx[i]), xx[i]--;
xx[n] = xx[n - 1] + 1;
solve(0);
lower = -1, upper = xx[n - 1] + 1;
while (upper - lower > 1) {
int d = (lower + upper) / 2;
if (solve(d))
upper = d;
else
lower = d;
}
solve(upper);
ans += (k_ - k) * upper - 1;
printf("%d\n", ans);
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... |