Submission #705295

# Submission time Handle Problem Language Result Execution time Memory
705295 2023-03-03T20:52:29 Z rainboy Semiexpress (JOI17_semiexpress) C
100 / 100
1 ms 300 KB
#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

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 time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 288 KB Output is correct
9 Correct 0 ms 288 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 288 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 288 KB Output is correct
9 Correct 0 ms 288 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 288 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 284 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 300 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 284 KB Output is correct
30 Correct 0 ms 212 KB Output is correct