Problem 01knapsack
User PerihelionfromAphelion
Submission Time 2026-06-09 22:37:44
Score 0
Max Time N/A
Max Memory N/A

Compile Error

01knapsack.cpp: In function ‘int main()’:
01knapsack.cpp:9:15: error: conflicting declaration ‘std::vector<int> w’
9 | vector <int> w(n + 1);
| ^
01knapsack.cpp:7:9: note: previous declaration as ‘int w’
7 | int n, w, i, j;
| ^
01knapsack.cpp:12:13: error: invalid types ‘int[int]’ for array subscript
12 | cin >> w[i] >> v[i];
| ^
01knapsack.cpp:16:23: error: invalid types ‘int[int]’ for array subscript
16 | for (j = w; j >= w[i]; j--) {
| ^
01knapsack.cpp:17:33: error: invalid types ‘int[int]’ for array subscript
17 | dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
| ^