题意

题目链接

Sol

好好读题 => 送分题

不好好读题 => 送命题

开始想了\(30\)min数据结构发现根本不会做,重新读了一遍题发现是个傻逼题。。。

\(C_{i, j} = a[i] * b[j]\)

根据乘法分配律,题目就变成了在数组\(a, b\)中分别选一段连续的区间,要求权值和相乘\(<= X\),最大化区间长度乘积

\(n^2\)模拟一下即可

#include<bits/stdc++.h>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define rg register
#define pt(x) printf("%d ", x);
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
#define chmin(x, y) (x = x < y ? x : y)
using namespace std;
const int MAXN = 2001, INF = 1e18 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
} int N, M, a[MAXN], b[MAXN], f[MAXN], g[MAXN], Lim, ans;
main() {
N = read(); M = read();
for(int i = 1; i <= N; i++) a[i] = read();
for(int i = 1; i <= M; i++) b[i] = read();
memset(f, 0x7f, sizeof(f));
memset(g, 0x7f, sizeof(g));
Lim = read();
for(int i = 1; i <= N; i++) {
int mn = 0;
for(int j = i; j <= N; j++) mn += a[j], chmin(f[j - i + 1], mn);
}
for(int i = 1; i <= M; i++) {
int mn = 0;
for(int j = i; j <= M; j++) mn += b[j], chmin(g[j - i + 1], mn);
}
for(int i = 1; i <= N; i++) {
for(int j = 1; j <= M; j++) {
if(f[i] * g[j] <= Lim)
ans = max(ans, j * i);
}
}
cout << ans;
return 0;
}

最新文章

  1. sqlMapConfig.xml配置文件详解
  2. 单机版搭建Hadoop环境图文教程详解
  3. Register/unregister a dll to GAC
  4. Delphi的类型转换 good
  5. CJOJ 1943 【重庆八中模拟赛】寻找代表元(二分图最大匹配)
  6. CentOS 7 学习(四)Git配置(一)
  7. 【NOI2014】起床困难综合症(贪心)
  8. 聊聊OSM
  9. css的transform属性让子元素在父元素里面垂直水平居中
  10. MongoDB日志文件过大的解决方法
  11. JSP内置对象概述
  12. Retrofit GreenDao开发中遇到的坑
  13. python 多线程和多进程
  14. Java的集合框架(第一次小结)
  15. .net图表之ECharts随笔07-自定义系列(多边形)
  16. C#使用ProtocolBuffer(ProtoBuf)进行Unity中的Socket通信
  17. laravel 懒加载
  18. 670. Maximum Swap
  19. linux环境下编译C++ 程序
  20. 渗透测试===使用BURPSUIT暴力破解某网站的手机验证码

热门文章

  1. 阿里巴巴前端面试分享-社招(p6)
  2. QuantLib 金融计算——基本组件之 DateGeneration 类
  3. Windows Server2008如何打开添加IIS服务器
  4. BZOJ_3224 Tyvj 1728 普通平衡树 【离散化+权值线段树】
  5. axiso 生产环境跨域配置(可用)
  6. 思维题--code forces round# 551 div.2
  7. 开源:我的Android新闻客户端,速度快、体积小、支持离线阅读、操作简便、内容展现形式丰富多样、信息量大、功能全面 等(要代码的留下邮箱)
  8. 【Ubuntu】执行定时任务(cron)
  9. 用Akka构建一个简易的分布式文件系统
  10. mysql-常用注入渗透手法