제출 #1078604

#제출 시각아이디문제언어결과실행 시간메모리
1078604SlayerOfDeathKnapsack (NOI18_knapsack)C++14
컴파일 에러
0 ms0 KiB
// Online C++ compiler to run C++ program online #include <bits/stdc++.h> using namespace std; typedef vector<pair<long long, long long>> vii; #define pb push_back #define all(x) x.begin(), x.end() const int V = 1e6 + 7; const int N = 1e5 + 7; const int S = 2e3 + 7; const int inf = 1e9; long long s, n, v[N], w[N], k[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE // freopen("test.inp", "r", stdin); //freopen("test.out", "w", stdout); #endif cin >> s >> n; for (int i = 0; i < n; i++) cin >> v[i] >> w[i] >> k[i]; int mx = *max_element(k, k + n); // Subtask 1 if (n == 1) { cout << v[1] * min(s / w[1], k[1]) << endl; } Subtask 2 & 3: Normal knapsack if (1 <= n && n <= 100 && mx <= 10) { long long dp[2001]; memset(dp, 0, sizeof dp); for (int i = 0; i < n; i++) for (int t = 0; t < k[i]; t++) for (int j = s; j >= w[i]; j--) { dp[j] = max(dp[j], dp[j - w[i]] + v[i]); } cout << dp[s] << endl; } }

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

knapsack.cpp: In function 'int main()':
knapsack.cpp:35:4: error: 'Subtask' was not declared in this scope
   35 |    Subtask 2 & 3: Normal knapsack
      |    ^~~~~~~
knapsack.cpp:30:7: warning: unused variable 'mx' [-Wunused-variable]
   30 |   int mx = *max_element(k, k + n);
      |       ^~