제출 #479396

#제출 시각아이디문제언어결과실행 시간메모리
479396rainboySličice (COCI19_slicice)C11
90 / 90
164 ms324 KiB
#include <stdio.h>
#include <string.h>

#define N	500
#define M	500
#define K	500

int max(int a, int b) { return a > b ? a : b; }

int main() {
	static int aa[N], bb[M + 1], dp[K + 1];
	int n, m, k, i, j, s, c;

	scanf("%d%d%d", &n, &m, &k);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	for (j = 0; j <= m; j++)
		scanf("%d", &bb[j]);
	memset(dp, -1, (k + 1) * sizeof *dp), dp[0] = 0;
	for (i = 0; i < n; i++)
		for (s = k; s >= 0; s--)
			for (c = 0; aa[i] + c <= m && c <= s; c++)
				if (dp[s - c] != -1)
					dp[s] = max(dp[s], dp[s - c] + bb[aa[i] + c]);
	printf("%d\n", dp[k]);
	return 0;
}

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

slicice.c: In function 'main':
slicice.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d%d", &n, &m, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
slicice.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
slicice.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d", &bb[j]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...