Submission #705295

#TimeUsernameProblemLanguageResultExecution timeMemory
705295rainboySemiexpress (JOI17_semiexpress)C11
100 / 100
1 ms300 KiB
#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)

semiexpress.c: In function 'main':
semiexpress.c:31:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%*d%d%d%lld%lld%lld%lld", &n, &k_, &c, &a, &b, &t), k_ -= n;
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.c:33:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d", &xx[i]), xx[i]--;
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...