제출 #1088203

#제출 시각아이디문제언어결과실행 시간메모리
1088203T0p_Knapsack (NOI18_knapsack)C++14
0 / 100
166 ms460 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++) { int w, k; long long v; scanf(" %lld %d %d",&v,&w,&k); for(int j=1 ; j<=s ; j++) { dp[i%2][j] = max(dp[i%2][j-1], dp[(i-1)%2][j]); for(long long t=1 ; t<=s && 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:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         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...