제출 #872796

#제출 시각아이디문제언어결과실행 시간메모리
872796rainboyLasers (NOI19_lasers)C11
100 / 100
107 ms13328 KiB
#include <stdio.h>

#define M	500000

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

int ll[M], rr[M];

void sort(int *hh, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, h = hh[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (ll[hh[j]] == ll[h])
				j++;
			else if (ll[hh[j]] < ll[h]) {
				tmp = hh[i], hh[i] = hh[j], hh[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = hh[j], hh[j] = hh[k], hh[k] = tmp;
			}
		sort(hh, l, i);
		l = k;
	}
}

int main() {
	static int ww[M], hh[M];
	int n, m, k, l, h, h_, i, wl, wr, r, ans;

	scanf("%d%d", &l, &n);
	m = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &k);
		wr = 0;
		for (h = 0; h < k; h++) {
			scanf("%d", &ww[h]);
			wr += ww[h];
		}
		wl = 0;
		for (h = 0; h < k; h++) {
			wl += ww[h];
			if (l - wr < wl)
				ll[m] = l - wr, rr[m] = wl, m++;
			wr -= ww[h];
		}
	}
	for (h = 0; h < m; h++)
		hh[h] = h;
	sort(hh, 0, m);
	ans = 0;
	for (h = 0, r = 0; h < m; h++) {
		h_ = hh[h];
		if (r < ll[h_])
			ans += rr[h_] - ll[h_], r = rr[h_];
		else if (r < rr[h_])
			ans += rr[h_] - r, r = rr[h_];
	}
	printf("%d\n", ans);
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

lasers.c: In function 'main':
lasers.c:36:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  scanf("%d%d", &l, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~
lasers.c:39:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%d", &k);
      |   ^~~~~~~~~~~~~~~
lasers.c:42:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |    scanf("%d", &ww[h]);
      |    ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...