제출 #126828

#제출 시각아이디문제언어결과실행 시간메모리
126828abacabaKas (COCI17_kas)C++14
100 / 100
305 ms87336 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const int M = 1e5 + 15; const int N = 5e2 + 15; int n, a[N], summ, ans = inf; int dp[N][M]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d", &a[i]); summ += a[i]; } for(int i = 1; i <= n; ++i) { for(int j = M - 1; j >= 0; --j) { if(!j || dp[i-1][j]) { dp[i][j + a[i]] = max(dp[i][j + a[i]], dp[i-1][j] + a[i]); dp[i][abs(j - a[i])] = max(dp[i][abs(j - a[i])], dp[i-1][j] + a[i]); dp[i][j] = max(dp[i][j], dp[i-1][j]); } } } cout << summ - dp[n][0] + dp[n][0] / 2; return 0; }

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

kas.cpp: In function 'int main()':
kas.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
kas.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
#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...