题意翻译
现在给出一个长度为N的a数列,一个长度为M的b数列. 现在需要构造出一个矩阵c,其中ci,j=ai×bj.再给出一个x,请在矩阵中找出一个最大的矩形,使得这个矩形中的所有值的和小于等于x.
题目描述
You are given two arrays aa and bb of positive integers, with length n and m respectively.
Let c be an n×m matrix, where ci,j=ai⋅bj .
You need to find a subrectangle of the matrix c such that the sum of its elements is at most x , and its area (the total number of elements) is the largest possible.
Formally, you need to find the largest number s such that it is possible to choose integers x1,x2,y1,y2 subject to n1≤x1≤x2≤n , m1≤y1≤y2≤m , (x2−x1+1)×(y2−y1+1)=s , and $sum_{i=x_1}^{x2}{sum_{j=y_1}^{y2}{c{i,j}}} leq x.$
输入输出格式
输入格式:
The first line contains two integers n and m ( 1≤n,m≤2000 ).
The second line contains n integers a1,a2,…,an ( 1≤ai≤2000 ).
The third line contains m integers b1,b2,…,bm ( 1≤bi≤2000 ).
The fourth line contains a single integer x ( 1≤x≤2⋅109 ).
输出格式:
If it is possible to choose four integersx1,x2,y1,y2 such that n1≤x1≤x2≤n , m1≤y1≤y2≤m , and x∑i=x1x2∑j=y1y2ci,j≤x , output the largest value of (