He has n watermelons and each one has a specific index denote as a. The watermelons...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <= n <= 2*105 ) Second line contains n integer a₁ ~ an which denote as the index of watermelons from top to bottom .( 1 <= a₁ <= n ) Third line contains n integer b₁ bn which denote as the order of the index that Osas' wants to eat.( 1 <= <= b₁ <= n ) Output output contains one line. output n integer means the number of watermelons that each time Osas eat. Separate each number by a blank but don't print the blank after the last number. remember to print \n at the end of output. Sample Input Download 5 53214 23451 Sample Output Download 30200 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 <= n <= 2*105 ) Second line contains n integer a₁ ~ an which denote as the index of watermelons from top to bottom .( 1 <= a₁ <= n ) Third line contains n integer b₁ bn which denote as the order of the index that Osas' wants to eat.( 1 <= <= b₁ <= n ) Output output contains one line. output n integer means the number of watermelons that each time Osas eat. Separate each number by a blank but don't print the blank after the last number. remember to print \n at the end of output. Sample Input Download 5 53214 23451 Sample Output Download 30200
Expert Answer:
Answer rating: 100% (QA)
Time Compexity ON Space Complexity ON include include int main int n scanfd n int inputListn int ind... View the full answer
Related Book For
Probability and Statistical Inference
ISBN: 978-0321923271
9th edition
Authors: Robert V. Hogg, Elliot Tanis, Dale Zimmerman
Posted Date:
Students also viewed these programming questions
-
A grocery store has n watermelons to sell and makes $1.00 on each sale. Say the number of consumers of these watermelons is a random variable with a distribution that can be approximated by A pdf of...
-
N balls labeled 1 through N are placed in Box 1 while a Box 2 is initially empty. At each time instant, one of the N balls is chosen (with equally probability) and moved to the other box. Let X [k]...
-
If A and B are n à n matrices, then (A - B)2 = A2 - 2AB + B2. In this case answer true if the statement is always true and false otherwise. In the case of a true statement, explain or prove...
-
The homogeneous rectangular block having dimensions a-1.93, b=2.75 as shown, and mass m, rests on the inclined plane which is hinged about a horizontal axis through O. Calculate the minimum value of...
-
What are business strategies? Explain the three basic strategies from which entrepreneurs can choose. Give an example of each one.
-
Pure monopolies do not achieve allocative efficiency meaning that they do not produce the amount of output that maximizes the sum of and surplus.
-
If \(X_{t} \sim N\left(0, \sigma^{2} t ight)\) and \(Y_{t}=e^{X_{t}}\), calculate the pdf of \(Y_{t}\). Calculate \(\mathbf{E}\left[Y_{t} ight]\) and \(V\left(Y_{t} ight)\). Calculate the transition...
-
Using the data in BE4-6, journalize and post the entry on July 1 and the adjusting entry on December 31 for Craig Insurance Co. Craig uses the accounts Unearned Service Revenue and Service Revenue.
-
Consider a simple loan. Draw up a table that shows the present value (PV) given the following variables. Show all your calculations. < Present Value (PV) Cash Flow (CF) Interest Rate (i) Term (n)...
-
On December 1, Year 1, John and Patty Driver formed a corporation called Susquehanna Equipment Rentals. The new corporation was able to begin operations immediately by purchasing the assets and...
-
Question 4. Three point charges are located at the corners of a equilateral triangle as shown in the figure. ..12 y-axis Fig. 1 93 = +0.50 uC 10.0 cm 10.0 cm 9 = +0.50 pC 10.0 cm (a) Calculate the...
-
A car turns into a driveway that slopes upward at a \(9.0^{\circ}\) angle. The car is moving at \(6.5 \mathrm{~m} / \mathrm{s}\). If the driver lets the car coast, how far along the slope will the...
-
There is a photograph of a girl pushing on a large stone sphere. The sphere has a mass of \(8200 \mathrm{~kg}\) and a radius of \(90 \mathrm{~cm}\). Suppose that she pushes on the sphere tangent to...
-
It is friction that provides the force for a car to accelerate, so for high-performance cars the factor that limits acceleration isn't the engine; it's the tires. For typical rubber-on-concrete...
-
A group of students is making model cars that will be propelled by model rocket engines. These engines provide a nearly constant thrust force. The cars are light-most of the weight comes from the...
-
An airplane cruises at \(880 \mathrm{~km} / \mathrm{h}\) relative to the air. It is flying from Denver, Colorado, due west to Reno, Nevada, a distance of \(1200 \mathrm{~km}\), and will then return....
-
You are an investment advisor working in ABC financial advisory Pty Ltd. The majority of the clients in your company is high net wealth individuals. Billy is one of the clients of your company and he...
-
A simple random sample of 220 university students were asked what pasta they usually order and with which sauce. The preferences of these respondents are summarised below: Sauce Bolognese Pasta...
-
An insurance company sells an automobile policy with a deductible of one unit. Let X be the amount of the loss having pmf Where c is a constant. Determine c and the expected value of the amount the...
-
Let and 2 denote the mean and variance of the random variable X. Determine E[(X )/] and E{[(X )/]2}.
-
In a woolen mill, 100-yard pieces are inspected. In the last 20 observations, the following numbers of flaws were found: (a) Compute the control limits of the c chart and draw this control chart. (b)...
-
Understanding the Feds actions that are needed to stabilize the interest rate The diagram below shows three different money demand curves and a target interest rate i*. Fill in the table below using...
-
This section looks at US recessions over the past 60 years. To work out this problem, first obtain quarterly data on US output growth for the period 1960 to the most recent data from www.bea.gov....
-
This question asks you to examine the movements of investment and consumption before, during and after the recession of 2001. It also asks you to consider the response of investment and consumption...
Study smarter with the SolutionInn App