Maxtrix
Time limit2sMemory limit1024 MB
Given arrays A and B, find for each k from 1 to N the maximum of A_i + B_j - i*j over all i at most k at most j.
- Level
Medium7 of 10
- Topics
- Divide and conquer, Array, Math
- Solved
- No attempts yet
Problem
Two integer arrays of length are given. Define an matrix as follows.
For every integer with , compute .
Input
The first line contains the integer , the length of both arrays.
The second line contains , separated by spaces.
The third line contains , separated by spaces.
Output
Print lines with the answers.
Constraints
- The absolute value of every element of and is at most .