답안 #101748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101748 2019-03-19T20:06:17 Z Ort Sličice (COCI19_slicice) C
90 / 90
120 ms 1400 KB
#include<stdio.h>
#define MAX 505

int n, m, k, i, j, l;
int sets[MAX], values[MAX], dp[MAX][MAX];

int main() {
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++) scanf("%d",&sets[i]);
	for(i=0;i<m+1;i++) scanf("%d",&values[i]);
	for(i=0;i<n;i++)
		for(j=0;j<=k;j++)
			for(l=0;l<=j;l++) {
				if(sets[i]+j-l>m) continue;
				if(i-1>=0) {if(dp[i-1][l]+values[sets[i]+j-l]>dp[i][j]) dp[i][j] = dp[i-1][l]+values[sets[i]+j-l];}
				else if(values[sets[i]+j-l]>dp[i][j]) dp[i][j] = values[sets[i]+j-l];
			}
	printf("%d", dp[n-1][k]);
	return 0;
}

Compilation message

slicice.c: In function 'main':
slicice.c:8:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&m,&k);
  ^~~~~~~~~~~~~~~~~~~~~~~~
slicice.c:9:19: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0;i<n;i++) scanf("%d",&sets[i]);
                   ^~~~~~~~~~~~~~~~~~~~
slicice.c:10:21: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0;i<m+1;i++) scanf("%d",&values[i]);
                     ^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1280 KB Output is correct
2 Correct 4 ms 1280 KB Output is correct
3 Correct 104 ms 1400 KB Output is correct
4 Correct 102 ms 1272 KB Output is correct
5 Correct 120 ms 1236 KB Output is correct
6 Correct 116 ms 1240 KB Output is correct
7 Correct 105 ms 1208 KB Output is correct
8 Correct 104 ms 1332 KB Output is correct
9 Correct 96 ms 1272 KB Output is correct
10 Correct 102 ms 1280 KB Output is correct