Question: algorithms please use c language Problem #1. Programming Balls in the Pipelines Daecheon Kim is very interested in the game balls in the pipelines. In
Problem #1. Programming Balls in the Pipelines Daecheon Kim is very interested in the game balls in the pipelines. In the game, there are p pipelines. The i-th pipeline contains ni balls. The balls are labeled as the positive numbers such that 1 to ni in the first pipeline, nr+1 to ni+ n2 in the second pipeline and so on. He needs to get m special balls out but he does not have enough time to find every pipeline because he is very busy on coursework. Fortunately, he remembers the labels of all special balls Task Write a program to help him determine which pipelines contain the special balls. Input and Input is read from the text file ball.inp consisting of: -The first line contains a single integer p, the number of pipelines The second line contains p integers n, n2,, np, where ni is the number of balls in the i-th pipeline - The third line contains single integer m (1sms 105), the number of special balls. +np), the labels The fourth line contains m integers si, S2,., Sm (1s sSn+n2+ of the special balls. Output is written to the text file ball.out consisting of - m lines: the j-th line contain an integer, representing the number of the pipeline which contains the special ball s. Example ball.in ball.out 5 27349 1 25 11 Limitation: -1sps 105 - 1sn,S 10 Processing time of the proposed algorithm s 1 second
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
