|
||||||||||
Problem B. Memory BanksTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3492 Accepted Submission(s): 603 Problem Description We have purchased 60 different types of memory banks, typed as 0 to 59, A bank of type i has 2^i memory capacity. We have $X_i$ memory banks of type i. We also have n workstations numbered from 1 to n. The $i_th$ workstation needs exactly (no more and no less) $W_i$ memory capacity to work. Each workstation can use unlimited amount of memory banks, Total memory capacity of this workstation is the sum of capacity of all memory banks it used. We need to make all workstations work and calculate the total capacity of unused memory banks, can you help us? Input Input is given from Standard Input in the following format: $X_0$ ... $X_{59}$ n $W_1$ ... $W_n$ Constraints 0 ≤ $X_i$ ≤ 2^60 1 ≤ n ≤ 100000 0 ≤ $W_i$ ≤ 2^60 All of them are integers. Output Print one line denotes the answer. If it is possible to make all workstations work, output a single number represents the total capacity of unused memory banks. It maybe very large, you should modulo 1000000007(10^9 + 7) Otherwise output -1 Sample Input
Sample Output
Source | ||||||||||
|