# Codeforces_c. Maximum Subrectangle

Source: Internet
Author: User

Http://codeforces.com/contest/1060/problem/C

Test instructions

The length of a and B arrays is n, M, respectively. Matrix C,CIJ=AI*BJ. In C, find a sub-matrix, the sub-matrix of all elements and not less than X, the maximum area of such a sub-matrix.

Ideas:

1, the matrix element and converted to (AI+......+AJ) * (BK+......+BL) Form, that is, a continuous element in a array and multiplied by the B array of successive elements and.

2, because only asked to find the maximum area, so long and wide starting point of the location of any arbitrary, so just a, b array of all the continuous length of the smallest element and (example, A's length of 5 continuous segment element and the minimum value)

Finally, the length and width of the sub-matrices are enumerated in sequence.

`#include <cstdio>#include<iostream>using namespacestd;#defineLL Long LongintMain () {LL x; intn,m,num1[2005],num2[2005]; intsub1[2005],sub2[2005],sum1[2005],sum2[2005]; sum1[0]=sum2[0]=0;  while(SCANF ("%d%d", &n,&m)! =EOF) {         for(intI=1; i<=n; i++) {scanf ("%d",&Num1[i]); Sum1[i]=sum1[i-1]+Num1[i]; Sub1[i]= -* -; }         for(intI=1; i<=m; i++) {scanf ("%d",&Num2[i]); Sum2[i]=sum2[i-1]+Num2[i]; Sub2[i]= -* -; } scanf ("%i64d",&x);  for(intI=1; i<=n; i++)             for(intJ=i; j<=n; J + +)            {                intlen=j-i+1; Sub1[len]=min (sub1[len],sum1[j]-sum1[i-1]); }         for(intI=1; i<=m; i++)             for(intJ=i; j<=m; J + +)            {                intlen=j-i+1; Sub2[len]=min (sub2[len],sum2[j]-sum2[i-1]); }        intres=0;  for(intI=1; i<=n;i++)             for(intj=1; j<=m;j++)                if(LL) sub1[i]*sub2[j]<=x)//two sub multiply may be super int res=max (res,i*j); printf ("%d\n", RES); }    return 0;}`

Codeforces_c. Maximum Subrectangle

Related Keywords:

### Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.