Codeforces Round 513 (Div.1+Div.2)
10月4号的比赛,因为各种原因(主要是懒),今天才写总结……
Div1+Div2,只做出两个题+迟到\(20min\),日常掉\(rating\)……
\(\rm{A.Phone\;Numbers}\)
很水的一道题目,直接输出cout<<min(n/11,tot);(\(tot\)为数字\(8\)的数量)
\(\mathcal{Maximum\;Sum\;of\;Digits}\)
一点小贪心,我们让\(9\)最多就行了,证明吗……感性的理解一下吧
\(\mathfrak{Maximum\;Subrectangle}\)
因为矩阵的元素\(C_{i,j}=a_i\times b_i\),所以
\(\sum_{i=x_1}^{x2}{\sum_{j=y_1}^{y2}{C_{i,j}}}=(sumx[x_2]-sumx[x_1-1])\times (sumy[x_2]-sumy[x_1-1])\)
其中sumx和sumy是\(a\)数列和\(b\)数列的前缀和。这样我们就可以\(O(n^2)\)处理出子矩阵长一定时候的最小值和宽一定时的最小值,然后\(O(1)\)判断。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long sumx[2010],sumy[2010],minx[2010],miny[2010];
long long read(){
int k=0,f=1; char c=getchar();
for(;c<'0'||c>'9';c=getchar())
if(c=='-') f=-1;
for(;c>='0'&&c<='9';c=getchar())
k=k*10+c-48;
return k*f;
}
int main(){
int n=read(),m=read();
memset(minx,127,sizeof(minx)), memset(miny,127,sizeof(miny));
for(int i=1;i<=n;i++) sumx[i]=sumx[i-1]+read();
for(int i=1;i<=m;i++) sumy[i]=sumy[i-1]+read();
//====预处理长宽一定时的最小值
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
minx[i]=min(minx[i],sumx[j]-sumx[j-i]);
}
}
//====判断并记录ans
for(int i=1;i<=m;i++){
for(int j=i;j<=m;j++){
miny[i]=min(miny[i],sumy[j]-sumy[j-i]);
}
}
int x=read(),ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
if(minx[i]*miny[j]<=x) ans=max(ans,i*j);
}
cout<<ans;
return 0;
}
Codeforces Round 513 (Div.1+Div.2)的更多相关文章
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- Educational Codeforces Round 39 (Rated for Div. 2) G
Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
- Educational Codeforces Round 60 (Rated for Div. 2) 题解
Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...
随机推荐
- excel常用函数之find,left,right,mid,len
mid =MID(A2,FIND("时间",A2)+2,10) 第一个 : 提取对象 第二个: 开始位置 第三个: 提取多少 find =FIND(“时间”,A2,1) 第一个: ...
- IntelliJ IDEA 中使用region代码折叠
我使用的版本为2018.3,如下图: 选中要折叠的代码,使用快捷键:Ctrl+Alt+T,打开Surround With菜单,点击region...endregion Comments项(红框),如下 ...
- memcached 扩展安装(windows)
在脚本之家里下载扩展压缩包 https://www.jb51.net/softs/392873.html 安装扩展前得先安装memcached并启动 下载完扩展压缩包解压并找到对应自己php版本 复制 ...
- 计蒜课/ 微软大楼设计方案/中等(xjb)
题目链接:https://nanti.jisuanke.com/t/15772 题意:中文题诶- 思路:对于坐标为p1(x1, y1), p2(x2, y2) 的两个核心, 其中 x1 <= x ...
- es备份索引
1.解压https://github.com/medcl/esm-abandonedhttps://github.com/medcl/esm-abandoned/releases tar xf lin ...
- day9函数作业详解
1.day9题目 1,整理函数相关知识点,写博客. 2,写函数,检查获取传入列表或元组对象的所有奇数位索引对应的元素,并将其作为新列表返回给调用者. 3,写函数,判断用户传入的对象(字符串.列表.元组 ...
- xml布局文件
https://blog.csdn.net/u013475386/article/details/44339035 gravity写在容器中中 layout_gravity写在控件中 layout_m ...
- NET Core Web发布包
给ASP.NET Core Web发布包做减法 https://www.cnblogs.com/sheng-jie/p/9122582.html 1.引言 紧接上篇:ASP.NET Core Web ...
- JavaSE---jar文件
1.当一个应用程序开发完成后,大致有3种方式发布: 1.1 使用平台相关的编译器将整个应用编译成平台相关的可执行文件: 1.2 为整个应用编辑一个批处理文件: 1.3 将应用程序制作为一个可执行的ja ...
- 使用cp命令拷贝目录下指定文件外的其他文件
shopt -s extglob cp test/!(abc*) test2/ cp test目录下除了以abc开头的其他文件 如果是除去多个文件的话使用 !(a|b) ; 注意不要多加空 ...