제출 #868568

#제출 시각아이디문제언어결과실행 시간메모리
868568PbezzKnapsack (NOI18_knapsack)C++14
73 / 100
1056 ms2768 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair const ll MAXN = 1e6+5; const ll INF = 1e5+5; const ll MOD = 1e9+7; int main() { ll s,n; //cin>>s>>n; scanf("%lld %lld", &s, &n); ll v,w,k; ll obj[n+1][3]; for(int i=1;i<=n;i++){ //cin>>v>>w>>k; scanf("%lld %lld %lld",&v, &w, &k); obj[i][0]=v; obj[i][1]=w; obj[i][2]=k; } ll dp[s+1]; for(int j=0;j<=s;j++)dp[j]=0; for(int i=1;i<=n;i++){ for(int j=s;j>=0;j--){ for(ll freq=1;freq<=obj[i][2];freq++){ if(j-freq*obj[i][1]<0)break; dp[j] = max(dp[j] , dp[j-freq*obj[i][1]]+freq*obj[i][0]); } } } printf("%lld",dp[s]); //cout<<dp[s]<<'\n'; return 0; }

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

knapsack.cpp: In function 'int main()':
knapsack.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%lld %lld", &s, &n);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%lld %lld %lld",&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...