Submission #1269417

#TimeUsernameProblemLanguageResultExecution timeMemory
1269417sepehrfazliiiKnapsack (NOI18_knapsack)C++20
73 / 100
1093 ms416 KiB
#include <bits/stdc++.h>
using namespace std;

int main() 
{
    int s, n;
    cin >> s >> n;
    int dp[s + 10] = {0};

    for(int i = 0; i < n; i++) 
	{
        int v , w , k; cin >> v >> w >> k;
        for (int j = s; j >= 0; j--) 
		{
            for(int c = 1; c <= k and c * w <= j; c++) 
			{
                dp[j] = max(dp[j] , dp[j - c * w] + c * v);
            }
        }
    }
    cout << dp[s] << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...