제출 #868566

#제출 시각아이디문제언어결과실행 시간메모리
868566PbezzKnapsack (NOI18_knapsack)C++14
0 / 100
0 ms348 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() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll s,n; cin>>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:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   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...