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轮构成,使用常见的“加权 ...
随机推荐
- Arduino通过L9110进行电机控制
L9110S是为控制和驱动电机设计的两通道推挽式功率放大专用集成电路器件,将分立电路集成在单片IC之中,使外围器件成本降低,整机可靠性提高. 该芯片有两个TTL/CMOS兼容电平的输入,具有良好的抗干 ...
- Plugin 'Lombok Plugin' is incompatible with this installation
作者:13 GitHub:https://github.com/ZHENFENG13 版权声明:本文为原创文章,未经允许不得转载. Installation Error Plugin 'Lombok ...
- 朱晔和你聊Spring系列S1E7:简单好用的Spring Boot Actuator
阅读PDF版本 本文会来看一下Spring Boot Actuator提供给我们的监控端点Endpoint.健康检查Health和打点指标Metrics等所谓的Production-ready(生产环 ...
- wtf_1234
好无聊啊,今天困的厉害. 不想做任何事情 wtf bitch!
- Python全栈开发之路 【第十九篇】:Bootstrap
一.下载和基本使用 官方地址:www.bootcss.com 二.响应式介绍 1.@meida 媒体查询 (1)响应式页面 为了页面能够适应不同工具的屏幕大小的限制,而开发的一种自适应页面,即 一次开 ...
- OO生存指南P1
写在OO作业之前 在正式写oo作业之前,先说一些“废话”吧,就当是对oo的吐槽. 事实上,早在大一的时候,听说数分很难,然而事实证明数分并没有有让我通宵的体验. 在大二上的时候有一门课叫祭祖,号称是第 ...
- POJ - 2528 区间离散化,线段树区间修改,区间询问
这个题非常有意思的地方是,我们发现区间[1,4]和[5,8]是紧挨着的,因为这个的数代表的是一段区间,原本我们对于普通的离散, a[1]=1,a[2]=5,a[3]=6,a[4]=8;数组下标就是重新 ...
- Oja’s rule
目录 Oja's rule 背景 Hebbian learning 主要的一些理论 论文里面一些主要的假设 引理1 引理2 引理3 定理1 LEMMA 3(ALL) 引理 4 定理 2 定理 3(关于 ...
- 2017湘潭大学邀请赛H题(树的直径)
链接:https://www.icpc.camp/contests/4mYguiUR8k0GKE H. Highway The input contains zero or more test cas ...
- 【转】shell之for、while、until循环
一.简介 Shell编程中循环命令用于特定条件下决定某些语句重复执行的控制方式,有三种常用的循环语句:for.while和until.while循环和for循环属于“当型循环”,而unti ...