제출 #448531

#제출 시각아이디문제언어결과실행 시간메모리
448531rainboyKas (COCI17_kas)C11
70 / 100
109 ms1860 KiB
#include <stdio.h> #include <string.h> #define S 100000 int max(int a, int b) { return a > b ? a : b; } int main() { static int dp[S * 2 + 1], dq[S * 2 + 1]; int n, sum; scanf("%d", &n); memset(dp, -1, (S * 2 + 1) * sizeof *dp), dp[S] = 0; sum = 0; while (n--) { int c, s; scanf("%d", &c); sum += c; memcpy(dq, dp, (S * 2 + 1) * sizeof *dp); for (s = 0; s <= S; s++) if (dp[s] != -1) dq[s - c] = max(dq[s - c], dp[s] + c), dq[s + c] = max(dq[s + c], dp[s] + c); memcpy(dp, dq, (S * 2 + 1) * sizeof *dq); } printf("%d\n", sum - dp[S] / 2); return 0; }

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

kas.c: In function 'main':
kas.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
kas.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d", &c);
      |   ^~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...