Submission #850185

#TimeUsernameProblemLanguageResultExecution timeMemory
850185alexz1205Knapsack (NOI18_knapsack)C++14
73 / 100
1046 ms1368 KiB
#include <iostream> using namespace std; const int S = 2000, N = 1e5; int arr[S+1]; int main() { int s, n; cin >> s >> n; for (int x = 0; x < n; x ++){ int v, w, k; cin >> v >> w >> k; k = min(k, s/w); for (int x = 0; x < k; x ++){ for (int i = s-w; i >= 0; i --){ arr[i+w] = max(arr[i+w], arr[i]+v); } for (int i = 1; i <= s; i ++){ arr[i] = max(arr[i], arr[i-1]); } } } cout << arr[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...