# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1033291 | 2024-07-24T16:06:07 Z | vjudge1 | Knapsack (NOI18_knapsack) | C++17 | 1000 ms | 48216 KB |
#include <bits/stdc++.h> using namespace std; #define int long long void solve() { int s, n; cin >> s >> n; vector<int> dp(s + 1, 0); for (int i = 0; i < n; ++i) { int v, w, k; cin >> v >> w >> k; for (int b = 1; k > 0; b *= 2) { int num = min(b, k); k -= num; int tv = num * v; int tw = num * w; for (int j = s; j >= tw; --j) { dp[j] = max(dp[j], dp[j - tw] + tv); } } } cout << *max_element(dp.begin(), dp.end()) << '\n'; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // Directly use C-style I/O for even faster performance #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1044 ms | 48208 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1098 ms | 48216 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1098 ms | 48216 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1044 ms | 48208 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1044 ms | 48208 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |