답안 #490937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
490937 2021-11-29T22:26:38 Z rainboy Segway (COI19_segway) C
0 / 100
15 ms 204 KB
#include <stdio.h>
#include <string.h>

#define N	20000
#define X	300
#define INF	0x3f3f3f3f

int min(int a, int b) { return a < b ? a : b; }

int main() {
	static int ss[N][3], xx[N], yy[N], tt[N], kk[X + 1];
	static char accel[X + 1];
	int n, m, h, i, x;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		for (h = 0; h < 3; h++)
			scanf("%d", &ss[i][h]);
	scanf("%d", &m);
	for (h = 0; h < m; h++) {
		scanf("%d", &x);
		accel[x] = 1;
	}
	for (i = 0; i < n; i++)
		tt[i] = ss[i][0];
	while (1) {
		int t;

		t = INF;
		for (i = 0; i < n; i++)
			if (xx[i] != X)
				t = min(t, tt[i]);
		if (t == INF)
			break;
		for (i = 0; i < n; i++)
			if (xx[i] != X && tt[i] == t) {
				xx[i]++;
				if (xx[i] < X && accel[xx[i]] && yy[i] <= xx[i])
					yy[i] = -1;
			}
		memset(kk, 0, (X + 1) * sizeof *kk);
		for (i = 0; i < n; i++)
			kk[xx[i]]++;
		for (x = X - 1; x >= 0; x--)
			kk[x] += kk[x + 1];
		for (i = 0; i < n; i++)
			if (yy[i] == -1)
				yy[i] = xx[i] + kk[xx[i] + 1] % 20;
		for (i = 0; i < n; i++)
			if (xx[i] != X && tt[i] == t)
				tt[i] = yy[i] <= xx[i] ? t + ss[i][xx[i] / (X / 3)] : t + 1;
	}
	for (i = 0; i < n; i++)
		printf("%d\n", tt[i]);
	return 0;
}

Compilation message

segway.c: In function 'main':
segway.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
segway.c:18:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |    scanf("%d", &ss[i][h]);
      |    ^~~~~~~~~~~~~~~~~~~~~~
segway.c:19:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%d", &m);
      |  ^~~~~~~~~~~~~~~
segway.c:21:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", &x);
      |   ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 15 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 15 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -