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 ...
随机推荐
- 微调Inception V3网络-对Satellite分类
目录 1. 流程概述 2. 准备数据集 2.1 Satellite数据集介绍 3. Inception V3网络 4. 训练 4.1 基于Keras微调Inception V3网络 4.2 Keras ...
- SpringBoot(1)—启动原理之SpringApplication对象的创建
创建SpringApplication对象 SpringBoot版本为 2.1.1.RELEASE @SpringBootApplication public class SpringbootDemo ...
- ASPNET Core 2.x中的Kestrel服务器
原文链接 Kestrel是一个基于libuv的跨平台ASP.NET Core web服务器,libuv是一个跨平台的异步I/O库.ASP.NET Core模板项目使用Kestrel作为默认的web服务 ...
- NET full stack framework
NFX UNISTACK 介绍 学习.NET Core和ASP.NET Core,偶然搜索到NFX UNISTACK,现翻译一下Readme,工程/原文:https://github.com/aumc ...
- HDU 1024 A - Max Sum Plus Plus DP + 滚动数组
http://acm.hdu.edu.cn/showproblem.php?pid=1024 刚开始的时候没看懂题目,以为一定要把那n个数字分成m对,然后求m对中和值最大的那对 但是不是,题目说的只是 ...
- 从一个LocalDateTime引发的疑问
一 公司有同事部署出错,然后查日志,找时间,从k8s得到的时间是 2017-06-16T09:38:48.580 +0000,然后他就纳闷了,因为他根本不会在9点部署好吧,而且9点大多数程序员都没开 ...
- 4.词法结构-JavaScript权威指南笔记
今天是第二章.所谓词法结构(lexical structure),就是写代码中最基本的东西,变量命名,注释,语句分隔等,这是抄书抄的... 1.字符集,必须是Unicode,反正Unicode是ASC ...
- UIcollectionView 实现 轮番图
UICollectionView 用作轮番图的实现,demo 地址:https://github.com/SummerHH/YJCYCleCollectionVIew #import <UIKi ...
- JAVA基础之线程
个人理解: 在相同的进程也就是运行同样的程序的前提下,线程越多效率越快!当然硬件也是个障碍!为了提高效率,可以多创建线程,但是也不是越多越好,这就需要了线程池进行管理!需要知道的线程实现的方法:继承T ...
- Redis集群批量操作
Redis在3.0版正式引入了集群这个特性,扩展变得非常简单.然而当你开心的升级到3.0后,却发现有些很好用的功能现在工作不了了, 比如我们今天要聊的pipeline功能等批量操作. Redis集群是 ...