eolymp
bolt
Try our new interface for solving problems
Problems

Theater revenue

Theater revenue

The theater has $n$ rows with $m$ seats. Two matrices are given. The first matrix contains the ticket prices for each seat. The second matrix tells which tickets are sold and which are not ($1$ means the ticket is sold for a corresponding seat, $0$ is not sold). Determine the total revenue from the performance. \InputFile The first line contains $n$ and $m~(n, m \le 500)$. Then the matrix with ticket prices is given ($n$ lines with $m$ numbers, each number ranges from $0$ to $10000$). Then given the matrix of sold tickets --- $n$ lines with $m$ numbers. \OutputFile Print the total revenue from the ticket sales. \includegraphics{https://static.eolymp.com/content/r7/r774iu2m5t1s59mgrivuc55kkc.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
3 3
1 2 3
4 5 6
7 8 9

1 0 1
0 1 0
1 0 1
Output example #1
25