답안 #20231

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20231 2016-05-17T17:47:15 Z kgy5809 앱 (KOI13_app) C
0 / 21
2 ms 0 KB
#include <stdio.h>

int m[100], c[100];
int N, M;

void main()
{
   int i, j, t;
   int dp[10000] = { 0 };
   scanf("%d%d", &N, &M);
   for (i = 0; i<N; scanf("%d", m + i++));
   for (i = 0; i<N; scanf("%d", c + i++));
   for (t = i = 0; i<N; i++)t += c[i];
   for (i = 0; i<N; i++)
   {
      for (j = t; j >= c[i]; j--)
      {
         if (dp[j]<dp[j - c[i]] + m[i])
         {
            dp[j] = dp[j - c[i]] + m[i];
         }
      }
   }
   for (i = 0; i <= t; i++)
   {
      if (dp[i] >= M)break;
   }
   printf("%d", i);
}

Compilation message

app.c:6:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main()
      ^
app.c: In function 'main':
app.c:10:4: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d", &N, &M);
    ^
app.c:11:21: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
    for (i = 0; i<N; scanf("%d", m + i++));
                     ^
app.c:12:21: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
    for (i = 0; i<N; scanf("%d", c + i++));
                     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 0 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero