Submission #703292

#TimeUsernameProblemLanguageResultExecution timeMemory
703292pahnKnapsack (NOI18_knapsack)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 1e3+5; const int M = 1e9+7; using vi = vector<int>; #define ll long long #define f first #define s second #define pii pair<int,int> #define pb push_back #define mp make_pair #define el '\n' ll s,n, a[mxN], b[mxN], c[mxN], dp[mxN][10005]; void solve() { cin >> m >> n; for (int i = 1; i <= n; ++i) cin >> b[i] >> a[i] >> c[i]; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { for (int z = 0; z <= c[i]; ++z){ if (z*a[i] <= j) dp[i][j] = max(dp[i][j], dp[i-1][j - z*a[i]] + b[i]*z); } } } cout << dp[n][m]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; // cin >> t; t = 1; while(t--) { solve(); } return 0; }

Compilation message (stderr)

knapsack.cpp: In function 'void solve()':
knapsack.cpp:15:9: error: 'm' was not declared in this scope
   15 |  cin >> m >> n;
      |         ^