In the deep archives of the Temporal Institute, a chrononaut named Vera prepares for a time-jump. The fabric of history is fraying at the edges, and a Quantum Coder anomaly — codenamed "0/1 Knapsack Problem" — must be resolved before the timeline collapses. The clocks on the walls spin backwards, and the air tastes of ozone. Vera's time-jet hums with energy. She has one chance to fix the anomaly. If her code is wrong, she could erase her own existence. In the deep archives of the Temporal Institute, a chrononaut named Vera prepares for a time-jump. The fabric of history is fraying at the edges, and a Quantum Coder anomaly — codenamed "0/1 Knapsack Problem" — must be resolved before the timeline collapses. The clocks on the walls spin backwards, and the air tastes of ozone. Vera's time-jet hums with energy. She has one chance to fix the anomaly. If her code is wrong, she could erase her own existence. Read N and W (count and capacity) on the first line, then N weights on the second line, then N values on the third line. Print the maximum value achievable with the given weight capacity. The temporal physics of the situation impose these unbreakable constraints: 1 <= N <= 100, 1 <= W <= 10^4 The archive's temporal scanners have locked onto these test echoes from alternate timelines: Input: 3 50 10 20 30 60 100 120 Output: 220 The countdown has begun. Vera's hands hover over the controls. She cannot see the future, but she can write a program that will shape it. Make every line count. The timeline depends on it. The temporal physics of the situation impose these unbreakable constraints: 1 <= N <= 100, 1 <= W <= 10^4 The archive's temporal scanners have locked onto these test echoes from alternate timelines: Input: 3 50 10 20 30 60 100 120 Output: 220 The countdown has begun. Vera's hands hover over the controls. She cannot see the future, but she can write a program that will shape it. Make every line count. The timeline depends on it. The path to mastering 0/1 Knapsack Problem is not one that can be walked in a single step. It demands patience, precision, and a deep respect for the boundaries that shape the problem. Many adventurers before you have attempted this trial and failed, their code crashing against the very constraints that the elders inscribed. But you have the tools. You have the training. You have reached the Quantum Coder tier, and that alone means the council believes in your potential. Look once more at the examples above. Trace the logic with your finger if you must. Consider the time and memory limits carefully, for they are not suggestions but strict laws of the arena. When you are ready, commit your solution. Let the compiler run. Let the test cases judge your work. If your code is true, the gates will open and you will move closer to the ultimate rank. If not, study the failure, sharpen your algorithm, and try again. For in the halls of CodeTikki, the only thing more important than success is the wisdom gained from the attempt. Remember that the Quantum Coder challenge is designed to test not just knowledge, but character. Every edge case is a lesson. Every time limit is a teacher. Every hidden test is a guardian at the gate. Do not rush. Let your code breathe. Let it be as clean as a mountain stream. When the final test passes, you will know that you have earned the title. Until then, code with courage, test with care, and never stop learning.
Constraints:
1 <= N <= 100, 1 <= W <= 10^4
