CodeForces 589B-Layer Cake-暴力模拟
刚看到这个题的想法是建图搜路,写出来了才发现这个做法不行,不能把每一个矩形看成不可分的点,因为最终的矩形可能两条边出现在不同矩形里。
后来看了题解才明白直接暴力就行。关键是明白最终的矩形两条边都在所给矩形中出现。
#include <cstdio>
#include <algorithm>
#include <cstring> using namespace std; typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 4e3+;
struct cake
{
int w,l;
cake(){}
bool operator < (const cake &b) const
{
return l > b.l;
}
}ck[maxn]; int N,len[maxn]; int main()
{
scanf("%d",&N); for(int i=;i<N;i++)
{
scanf("%d%d",&ck[i].w,&ck[i].l);
if(ck[i].w > ck[i].l) swap(ck[i].w,ck[i].l);
} sort(ck,ck+N); int m;
int answ,ansl;
ll ans = -INF; for(int i=;i<N;i++)
{
m = ;
for(int j=;j<N;j++)
{
if(ck[j].w >= ck[i].w)
{
len[m++] = ck[j].l;
}
}
for(int j=;j<m;j++)
{
ll res = (ll)ck[i].w*len[j]*(j+);
if(res > ans)
{
ans = res;
answ = ck[i].w;
ansl = len[j];
}
}
}
printf("%I64d\n%d %d\n",ans,answ,ansl); }
CodeForces 589B-Layer Cake-暴力模拟的更多相关文章
- CodeForces 589B Layer Cake (暴力)
题意:给定 n 个矩形是a*b的,问你把每一块都分成一样的,然后全放一块,高度都是1,体积最大是多少. 析:这个题,当时并没有完全读懂题意,而且也不怎么会做,没想到就是一个暴力,先排序,先从大的开始选 ...
- CodeForces - 589B(暴力+排序)
Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n ...
- CodeForces - 589B
题目链接:https://vjudge.net/contest/242578#problem/B Dasha decided to bake a big and tasty layer cake. I ...
- 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest, B. Layer Cake
Description Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping ...
- bnuoj 20832 Calculating Yuan Fen(暴力模拟)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=20832 [题意]: 给你一串字符串,求一个ST(0<ST<=10000),对字符串中字符 ...
- POJ 1013 小水题 暴力模拟
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35774 Accepted: 11 ...
- hdu_1006 Tick and Tick(暴力模拟)
hdu1006 标签(空格分隔): 暴力枚举 好久没有打题了,退队了有好几个月了,从心底不依赖那个人了,原来以为的爱情戏原来都只是我的独角戏.之前的我有时候好希望有个人出现,告诉自己去哪里,做什么,哪 ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- hihoCoder #1871 : Heshen's Account Book-字符串暴力模拟 自闭(getline()函数) (ACM-ICPC Asia Beijing Regional Contest 2018 Reproduction B) 2018 ICPC 北京区域赛现场赛B
P2 : Heshen's Account Book Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Description H ...
- 美团2018年CodeM大赛-资格赛 分数 暴力模拟
链接:https://www.nowcoder.com/acm/contest/138/D来源:牛客网 小胖参加了人生中最重要的比赛——MedoC资格赛.MedoC的资格赛由m轮构成,使用常见的“加权 ...
随机推荐
- Python股票分析系列——获得标普500的所有公司股票数据.p6
该系列视频已经搬运至bilibili: 点击查看 欢迎来到Python for Finance教程系列的第6部分. 在之前的Python教程中,我们介绍了如何获取我们感兴趣的公司名单(在我们的案例中是 ...
- Python股票分析系列——基础股票数据操作(一).p3
该系列视频已经搬运至bilibili: 点击查看 欢迎来到Python for Finance教程系列的第3部分.在本教程中,我们将使用我们的股票数据进一步分解一些基本的数据操作和可视化.我们将要使用 ...
- 使用matplotlib画饼图
import matplotlib.pyplot as pltx = [4, 9, 21, 55, 30, 18]labels = ['math', 'history', 'chemistry', ' ...
- Python_程序实现发红包
发红包 200块钱 20个红包 将200块随机分成20份 基础版本: import random ret = random.sample(range(1, 200 * 100), 19) ret = ...
- 02-安装linux系统
安装linux系统 需要准备的软件: 1.VMware-workstation-full-14.1.1.28517.exe 2.CentOS-6.5-x86_64-bin-DVD1.iso镜像文件 第 ...
- 学习bootstrap3
官方手册(英文):http://getbootstrap.com/docs/3.3/getting-started/ 中文文档:https://v3.bootcss.com/getting-start ...
- ascii、unicode、utf-8、gbk 区别
原文:https://blog.csdn.net/u010262331/article/details/46013905 ASCII:遇上0×10, 终端就换行: 遇上0×07, 终端就向人们嘟嘟叫: ...
- [转帖]windows7/windows NT介绍
windows7/windows NT介绍 原文应该是IT168发布的 但是一直没找到 感觉看了之后 明白了很多 技术都是互相融合的 没有严格意义上的对立直说. Windows 7/Windows ...
- Linux bc 命令简单学习
1. bash里面能够实现比较简单的四则运算 echo $((*)) 注意是 双括号+ $ 地址符号. 2. 但是比较复杂的 可能就难以为继了 比如不支持精度 3. 所以这里面需要使用 bc 命令来执 ...
- bnu——GCD SUM (莫比乌斯反演)
题目:GCD SUM 题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=39872 算法:莫比乌斯反演.优化 #include<stdio.h& ...