Krazy Golf
View as PDFMAPS Team is keeping up with the kids, and wants to revitalise Golf, a historically slow and methodical sport, with the hyper-popular gaming trend of a battle royale!
The golf course is a standard -hole course, however the scoring has been changed, because it makes way more sense for a higher score to mean a better golfer!
Each hole nets the player a certain amount of points, which accumulates throughout the course. However, at the end of every hole, there is a gate. If you do not have at least points, then you are eliminated from the competition!
One of the competitors, Lauren, has given you their scorecard - how many points they would likely score in each of the holes. She'd like to know how many holes she will get to play before being eliminated.
However, you don't always need to run the full -hole course for the competition - you're allowed to start at any of the holes, as long as you complete each consecutive hole until hole
, or you are eliminated.

You'd like to know, for every possible starting hole - how many holes Lauren would be able to play before being eliminated.
Input
Input will begin with a single integer (
) - the number of holes in the course.
2 lines will follow, each containing integers.
The first line specifies the gate values (
) - If, after completing hole
, you do not have
points, you are eliminated from the competition!
The second specifies the point values (
) - How many points Lauren can expect to receive from hole
.
Output
Output integers - representing how many holes Lauren would be able to play if starting at hole 1, 2, 3,
.
Example 1
Input
5
1 4 1 2 5
3 1 2 1 1
Output
5 1 3 1 1
Explanation
The reasoning for the sample output is provided below:

Comments