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轮构成,使用常见的“加权 ...
随机推荐
- MySQL 8 新特性之自增主键的持久化
自增主键没有持久化是个比较早的bug,这点从其在官方bug网站的id号也可看出(https://bugs.mysql.com/bug.php?id=199).由Peter Zaitsev(现Perco ...
- xadmin的使用
01-下载源码 GitHub地址:https://github.com/sshwsfc/xadmin # 安装xadmin 由于使用的是Django2.0的版本,所以需要安装xadmin项目djang ...
- Python做windows服务
Python做windows服务(多进程服务),并结束多进程 Python中_,__,__xx__的区别 在注册MyWinService服务时,再使用 "sc delete 服务器名称&qu ...
- 007-迅雷定时重启AutoHotkey脚本-20190411
;; 定时重启迅雷.ahk,;;~ 2019年04月11日;#SingleInstance,forceSetWorkingDir,%A_ScriptDir%DetectHiddenWindows,On ...
- Python入门-格式化输出
需求:将用户的姓名.年龄.工作.爱好 ,然后打印成以下格式: ------------ Info of Tom ------ Name : Tom Age : 22 Job : Teacher Hob ...
- [Offer收割]编程练习赛97
链接 [https://hihocoder.com/contest/offers97/problems] 题意 题目1 : 放置矩形 时间限制:10000ms 单点时限:1000ms 内存限制:256 ...
- Daily Scrum 12.19
Member Task on 12.19 Task on 12.20 仇栋民 请假 完成Task972 : 完成活动评分基础功能 康家华 完成 Task1004 : 百度map UI优化 完成Task ...
- Python2和Python3中urllib库中urlencode的使用注意事项
前言 在Python中,我们通常使用urllib中的urlencode方法将字典编码,用于提交数据给url等操作,但是在Python2和Python3中urllib模块中所提供的urlencode的包 ...
- Python之字符串操作
一.字符串特点 内容不可修改 password=' #内容不可修改 二.字符串常用方法 1..strip()方法 去字符串两边的空格和换行符 print(password.strip()) #去掉字符 ...
- Python爬虫:爬取人人都是产品经理的数据
爬取内容: 人人都是产品经理首页(www.woshipm.com)左侧[最新文章]下如图样式的文章标题.浏览量和缩略图. 思路: 1. 用BeautifulSoup解析网页 变量名 = Beautif ...