You have worked hard to collect snippets of stock data for training an AI to predict markets for day trading purposes.

computer science

Description

Stock 


You have worked hard to collect snippets of stock data for training an AI to predict markets for day trading purposes. However, in a bout of sleepless rage over friendships, a colleague wrote a program that sorted all the data in each snippet, thereby ruining your dream of making billions in the stock market. There is still hope! You plan on utilizing the partial information you gathered to help recover the original data collected by writing data recovery program.


The data you had initially stored was the value of a stock on a particular day (at fixed intervals) and the absolute change in the stock value (between the fixed intervals). Luckily, your sort method only sorted the stock values with respect to each other and the changes with respect to each other. You quickly realize that the number of valid data arrangements can be quite large. For this assignment your program should output only the number of possible data arrangements give the unsorted list of values and the unsorted list of price differences.


Suppose the values of a particular section were 1, 2, 3, 5, and 4. Then the absolute differences would be 1, 1, 2, and 1. The sorted values would become 1, 2, 3, 4, and 5. While the sorted absolute differences would be 1, 1, 1, and 2.


Input Specification The input will begin with an integer n (n ≤ 12), number data points for a given data set. The next line will each contain n space separated integers, ai (1 ≤ ai ≤ 10,000), representing the data points for the stock value on the given day. The next line contains n – 1 space separated integers, di (1 ≤ di ≤ 10,000), representing the absolute differences between stock values between the fixed intervals.


Related Questions in computer science category