Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2)C
Posted huluxin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2)C相关的知识,希望对你有一定的参考价值。
这题卡了还蛮久的,矩阵还是有一点陌生啊。
1 #include <iomanip> 2 #include <iostream> 3 #include <cstdio> 4 #include <cmath> 5 #include <cstring> 6 #include <algorithm> 7 #include <queue> 8 #include <stack> 9 #include <vector> 10 #include <map> 11 using namespace std; 12 const int nmax=2020; 13 long long a[nmax],b[nmax],prea[nmax],preb[nmax],lena[nmax],lenb[nmax]; 14 int main(int argc, char *argv[]) 15 { 16 long long n,m,x; 17 scanf("%I64d%I64d",&n,&m); 18 for(int i=1;i<=n;i++) 19 { 20 scanf("%I64d",&a[i]); 21 prea[i]=prea[i-1]+a[i]; 22 } 23 for(int i=1;i<=m;i++) 24 { 25 scanf("%I64d",&b[i]); 26 preb[i]=preb[i-1]+b[i]; 27 } 28 scanf("%I64d",&x); 29 memset(lena,0x3f3f3f3f,sizeof(lena)); 30 memset(lenb,0x3f3f3f3f,sizeof(lenb)); 31 for(int i=0;i<n;i++) 32 { 33 for(int j=i+1;j<=n;j++) 34 { 35 lena[j-i]=min(lena[j-i],prea[j]-prea[i]); 36 } 37 } 38 for(int i=0;i<m;i++) 39 { 40 for(int j=i+1;j<=m;j++) 41 { 42 lenb[j-i]=min(lenb[j-i],preb[j]-preb[i]); 43 } 44 } 45 long long sum=0; 46 for(int i=1;i<=n;i++) 47 { 48 for(int j=1;j<=m;j++) 49 { 50 if(lena[i]*lenb[j]<=x&&i*j>sum) 51 sum=i*j; 52 } 53 } 54 printf("%I64d",sum); 55 return 0; 56 }
以上是关于Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2)C的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2)
Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2)C
[Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) ](A~E)
Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) C D
Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) C. Maximum Subrectangle