제출 #1342496

#제출 시각아이디문제언어결과실행 시간메모리
1342496darkshadowzKnapsack (NOI18_knapsack)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;

int dp[2069];

signed main(){

    cin.tie(0); ios::sync_with_stdio(0);
    int w, n; cin >> w >> n;
    for(int i=1; i<=n; i++){
        int v, a, k; cin >> v >> a >> k;
        for(int j=1; k>0; j<<=1){
            int W = a*min(j,c), V = v*min(j,c);
            for(int x=w; x-W>=0; x--)
                dp[x] = max(dp[x], dp[x-W]+V);
            k -= j;
        }
    }
    cout << dp[w];

    return 0;
}

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

knapsack.cpp: In function 'int main()':
knapsack.cpp:14:29: error: 'c' was not declared in this scope
   14 |             int W = a*min(j,c), V = v*min(j,c);
      |                             ^
knapsack.cpp:16:44: error: 'V' was not declared in this scope
   16 |                 dp[x] = max(dp[x], dp[x-W]+V);
      |                                            ^