제출 #484006

#제출 시각아이디문제언어결과실행 시간메모리
484006T0p_Knapsack (NOI18_knapsack)C++14
12 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; long long dp[2][2005]; int main() { int s, n; scanf(" %d %d",&s,&n); for(int i=1 ; i<=n ; i++) { for(int j=1 ; j<=s ; j++) dp[i%2][j] = 0; int w, k; long long v; scanf(" %lld %d %d",&v,&w,&k); for(int j=1 ; j<=s ; j++) { dp[i%2][j] = dp[i%2][j-1]; for(int t=1 ; t<=k && j-w*t>=0 ; t++) dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][j-w*t] + v*t); } } printf("%lld\n",dp[n%2][s]); return 0; }

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

knapsack.cpp: In function 'int main()':
knapsack.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf(" %d %d",&s,&n);
      |     ~~~~~^~~~~~~~~~~~~~~~
knapsack.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf(" %lld %d %d",&v,&w,&k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...