Picking Specific Days
Riverbend Supply's dashboard lets a manager tick the days she wants on a comparison chart. The week's takings are stored in day order, and her tick-list comes back as day positions rather than day names. She is allowed to tick the same day twice, in which case the chart shows that day in two places, and she may tick days in any order she likes, because the chart draws them in the order she picked rather than in calendar order.
Task: Print the takings for the ticked days, in the order they were ticked.
Input
Four lines. The first holds n, how many days of takings there are. The second holds those n figures on a single line, separated by single spaces, in day order. The third holds m, how many ticks were made. The fourth holds those m day positions on a single line, separated by single spaces, counted from 0.
Output
One line holding m figures, separated by single spaces, in tick order. Write each as a whole number. A day ticked twice appears twice.
Example:
Input:
5
10 20 30 40 50
3
0 2 4
Output:
10 30 50
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in