Submission #1192503

#TimeUsernameProblemLanguageResultExecution timeMemory
1192503dprtoKnapsack (NOI18_knapsack)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define x first
#define y second
#define MASK(i) (1 << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define f(i, l, r) for(int i = l; i <= r; ++i)
const int mod = 1e9 + 7;
const int ars = 2e3 + 5;
const ll infll = 1e18;


int s, n, v[ars], w[ars], k[ars], dp[ars];
signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s >> n;

    for(int i = 1; i <= n; ++i){
        int v[i] >> w[i] >> k[i];
    }

    for(int i = 0; i <= s; ++i) dp[i] = 0;

    f(i, 1, n){
        for(int j = s; j >= w[i]; --j){
            for(int q = 1; q <= k[i] and q * w[i] <= j; ++k){
                dp[j] = max(dp[j], dp[j - q * w[i]] + q * v[i]);
            }
        }
    }

    cout << dp[s];


    return 0;
}

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:20:18: error: expected initializer before '>>' token
   20 |         int v[i] >> w[i] >> k[i];
      |                  ^~
knapsack.cpp:27:59: error: lvalue required as increment operand
   27 |             for(int q = 1; q <= k[i] and q * w[i] <= j; ++k){
      |                                                           ^