Submission #683949

# Submission time Handle Problem Language Result Execution time Memory
683949 2023-01-19T18:16:41 Z rainboy Long Distance Coach (JOI17_coach) C
0 / 100
0 ms 212 KB
#include <stdio.h>

#define N	200000
#define M	200002
#define INF	0x3f3f3f3f3f3f3f3fLL

long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }

int main() {
	static int cc[N];
	static long long rr[N], xx[M + 2];
	int n, m, c, b, b_, i, j;
	long long md, t, t1, t2, x_, ans, z;

	scanf("%lld%d%d%d%lld", &x_, &m, &n, &c, &md), m += 2;
	xx[0] = -1, xx[m - 1] = x_;
	for (j = 1; j + 1 < m; j++)
		scanf("%lld", &xx[j]);
	for (i = 0; i < n; i++)
		scanf("%lld%d", &rr[i], &cc[i]);
	ans = INF;
	for (b = 0; b < 1 << n; b++) {
		z = 0;
		for (i = 0; i < n; i++)
			if ((b & 1 << i) == 0)
				z += cc[i];
		b_ = 0;
		for (j = 1; j < m; j++) {
			t = max(xx[j - 1] + 1, (xx[j] + md) / md * md - md);
			for (i = 0; i < n; i++)
				if ((b & 1 << i) != 0)
					t = max(t, (xx[j] + md - rr[i]) / md * md - (md - rr[i]));
			t1 = (xx[j - 1] + md) / md * md - md;
			t2 = (xx[j] + md) / md * md - md;
			z += (max(t2 - t1, 0) / md) * c;
			for (i = 0; i < n; i++)
				if ((b_ & 1 << i) == 0) {
					t1 = (xx[j - 1] + md - rr[i]) / md * md - (md - rr[i]);
					t2 = (xx[j] + md - rr[i]) / md * md - (md - rr[i]);
					if (t1 < t2) {
						z += (max(min(t, t2) - t1, 0) / md) * c;
						if (t2 > t)
							b_ |= 1 << i;
					}
				}
		}
		ans = min(ans, z);
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

coach.c: In function 'main':
coach.c:16:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%lld%d%d%d%lld", &x_, &m, &n, &c, &md), m += 2;
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%lld", &xx[j]);
      |   ^~~~~~~~~~~~~~~~~~~~~
coach.c:21:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%lld%d", &rr[i], &cc[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 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -