Submission #591939

#TimeUsernameProblemLanguageResultExecution timeMemory
591939multifanblinksKnapsack (NOI18_knapsack)C++14
0 / 100
1 ms384 KiB
#include <iostream> using namespace std; typedef long long ll; const unsigned MAX = 100003, MAX_2 = 2003; int s, n; ll v[MAX], w[MAX], k[MAX], sack[MAX_2]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> s >> n; for (int i = 0; i < n; i++) cin >> v[i] >> w[i] >> k[i]; for (int i = 0; i < s; i++) sack[i] = 0; for (int i = 0; i < n; i++) for (int j = s; j >= 0; j--) for (int q = 1; q * v[i] <= j && q <= k[i]; q++) { sack[j] = max(sack[j], sack[j - q * v[i]] + q * w[j]); q++; } cout << sack[s]; 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...