Question: He has n watermelons and each one has a specific index denote as a. The watermelons are store in a cylindrical() box. Osas wants

He has n watermelons and each one has a specific index denote

as a. The watermelons are store in a cylindrical() box. Osas wantsto eat a watermelon indexed a;. But if the watermelon indexed a;

He has n watermelons and each one has a specific index denote as a. The watermelons are store in a cylindrical() box. Osas wants to eat a watermelon indexed a;. But if the watermelon indexed a; is not on the top, he needs to eat all watermelon above the watermelon indexed a;. For example if the index of watermelon from top to bottom is: 5, 3, 2, 1, 4. And Osas wants to eat watermelon which index is 2, then he need to eat watermelons which index are 5, 3, 2 at the same time. Osas has a list which is the order of index of watermelons he wants to eat which denoted as b. The length of the list is also n and all b; are distinct. Please help him calculate that each time he wants to eat a watermelon, how many watermelons he needs to eat at same time? For example if the index of watermelon from top to bottom is: 5, 3, 2, 1, 4. And the list Osas has is: 2, 3, 4, 5, 1. First time Osas will eat 3 watermelons(5,3,2). Second time because the watermelons that indexed 3 is already been eaten, Osas eat 0 watermelon. So on and so forth. In this example, you need to output: 3 0 2 0 0. Input input contains three lines. First line contains n the number of watermelons.( 1 Sample Input Download 5 53214 23451 Sample Output Download 30200

Step by Step Solution

3.47 Rating (170 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Time Compexity ON Space Complexity ON include include int main int n scanfd n int inputListn int ind... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!