#P10143. Code Block Commemoration Contest Score Prediction
Code Block Commemoration Contest Score Prediction
Code Block Commemoration Contest Score Prediction
In memory of the canceled CodeJam, little organizes a Code Block Commemoration Contest. There are problems and the contest lasts for seconds. The -th problem has a score of and is predicted by to be solved by little in seconds.
The problems have two types: result visible and result invisible. For result invisible problems, the evaluation result is revealed only after the contest ends, whereas for result visible problems the result is known immediately upon submission. Little has not decided the type of each problem yet.
Little will solve all the result visible problems first (in increasing order of their indices) and then solve all the result invisible problems (again in increasing order). He spends exactly seconds on the -th problem. Moreover, if the cumulative time spent on the -th problem and all previously solved problems does not exceed , a submission (which is always accepted) is generated for the -th problem.
For a given type assignment for the problems (a total of possibilities), let the score be the sum of scores for all problems that were submitted (i.e. solved before or at time ). The task is to compute the sum of scores over all possible assignments, modulo .
inputFormat
The first line contains two integers and .
The second line contains integers , where is the score of the -th problem.
The third line contains integers , where is the time (in seconds) required to solve the -th problem.
outputFormat
Output one integer: the sum of scores over all type assignments modulo .
sample
5 1
10
3
20