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 ...
随机推荐
- ue4学习资料
官网中文 https://docs.unrealengine.com/latest/CHN/index.html 官网英文 https://docs.unrealengine.com/latest/I ...
- tyvj4868 天天和不可描述
描述
- 2014-10-5 NOIP模拟赛
祖孙询问 (tree.pas/c/cpp) [问题描述] 已知一棵n个节点的有根树.有m个询问.每个询问给出了一对节点的编号x和y,询问x与y的祖孙关系. [输入格式] 输入第一行包括一个整数n表示节 ...
- 洛谷P1582 倒水
P1582 倒水 题目描述 一天,CC买了N个容量可以认为是无限大的瓶子,开始时每个瓶子里有1升水.接着~~CC发现瓶子实在太多了,于是他决定保留不超过K个瓶子.每次他选择两个当前含水量相同的瓶子,把 ...
- 解决windows下nginx中文文件名乱码
我的根目录文件夹放在d盘work文件夹下,一般这样配置 nginx\conf\nginx.conf location / { root D:/work; index index_bak.html; a ...
- qBittorrent+Flex搭建在线视频播放网站
BT下载工具qbittorrent(当然这里也有其他类似的工具可选如transmission等) 首先安装EPEL源: yum -y install epel-release 安装开发工具包: yum ...
- C# 文件异步操作
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- HDU1409 Is It a Number
http://acm.hdu.edu.cn/showproblem.php?pid=1409 没啥好说的,至今也不知道到底错在哪里了,看了discuss才过的 #include <iostrea ...
- 2017"百度之星"程序设计大赛 - 初赛(A)小C的倍数问题
Problem Description 根据小学数学的知识,我们知道一个正整数x是3的倍数的条件是x每一位加起来的和是3的倍数.反之,如果一个数每一位加起来是3的倍数,则这个数肯定是3的倍数. 现在给 ...
- php操作redis和memcache过期时间
php-redis 设置过期时间setTimeOut 命令行expireredis过期时间redis术语里面,把设置了expire time的key 叫做:volatile keys. 意思就是不稳定 ...