Submission #1023763

#TimeUsernameProblemLanguageResultExecution timeMemory
1023763vjudge1Knapsack (NOI18_knapsack)C++17
0 / 100
1 ms348 KiB
#include <iostream> #include <vector> using namespace std; int main() { int N, S; cin >> N >> S; vector<int> V(N), W(N), K(N); for (int i = 0; i < N; ++i) { cin >> V[i] >> W[i] >> K[i]; } vector<long long> dp(S + 1, 0); for (int i = 0; i < N; ++i) { for (int k = 1; K[i] > 0; k <<= 1) { int count = min(k, K[i]); K[i] -= count; for (int s = S; s >= W[i] * count; --s) { dp[s] = max(dp[s], dp[s - W[i] * count] + V[i] * count); } } } cout << dp[S] << endl; return 0; }
#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...