Need Help with ‘Workout for a Dumbbell’ Problem on Kattis – Wrong Output!

0
5
Asked By CuriousCoder42 On

Hey folks! I'm really stuck on the Kattis problem "Workout for a Dumbbell" and keep getting a Wrong Answer verdict. My code isn't passing the sample test case and seems to be outputting `100`, which is incorrect. This problem has Jim scheduling workouts on 10 machines, each getting used three times with specific times assigned for both usage and recovery. There's also another person using these machines, which adds complexity to the timing due to shared usage rules. I'm particularly confused about how to interpret the two-way waiting rule when both Jim and the other person want to use a machine at the same time. If anyone has insights or can point out where I might be going wrong, I'd really appreciate it!

3 Answers

Answered By GymGuru99 On

The key to tackling the "Workout for a Dumbbell" problem lies in understanding Jim's schedule alongside the other person's. You have to simulate the timing correctly, considering both their usage and recovery times. Make sure when Jim uses a machine, any time overlaps with the other person's usage is handled based on the waiting rules you mentioned. You're right to focus on using arrays to model the scheduling as described in your book. Just ensure you're aligning timings properly for both Jim and the other person as they alternate on the machines.

Answered By TechEnthusiast101 On

Definitely check how you are updating the next usage times for the other person after Jim's workouts. Each time Jim finishes using a machine, you need to evaluate the earlier start times for the other person based on recovery periods and re-align their schedule. If you're failing to catch those shifts, it could lead to the wrong output. Also, don’t forget to confirm that the last machine that Jim uses is considered at the end of his time on it, not during the recovery phase.

Answered By CodeWizardX On

It sounds like your two-way waiting implementation might need some adjustments. When Jim is done at a machine, any overlapping time for the other person should push their next use forward as you mentioned. A greedy approach can work, but make sure to adjust offsets for the other person's timing accurately after each of Jim's workouts. Have you considered testing edge cases like when their schedules align perfectly?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.