刚看到这个题的想法是建图搜路,写出来了才发现这个做法不行,不能把每一个矩形看成不可分的点,因为最终的矩形可能两条边出现在不同矩形里。

后来看了题解才明白直接暴力就行。关键是明白最终的矩形两条边都在所给矩形中出现。

  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. typedef long long ll;
  8. const int INF = 0x3f3f3f3f;
  9. const int maxn = 4e3+;
  10. struct cake
  11. {
  12. int w,l;
  13. cake(){}
  14. bool operator < (const cake &b) const
  15. {
  16. return l > b.l;
  17. }
  18. }ck[maxn];
  19.  
  20. int N,len[maxn];
  21.  
  22. int main()
  23. {
  24. scanf("%d",&N);
  25.  
  26. for(int i=;i<N;i++)
  27. {
  28. scanf("%d%d",&ck[i].w,&ck[i].l);
  29. if(ck[i].w > ck[i].l) swap(ck[i].w,ck[i].l);
  30. }
  31.  
  32. sort(ck,ck+N);
  33.  
  34. int m;
  35. int answ,ansl;
  36. ll ans = -INF;
  37.  
  38. for(int i=;i<N;i++)
  39. {
  40. m = ;
  41. for(int j=;j<N;j++)
  42. {
  43. if(ck[j].w >= ck[i].w)
  44. {
  45. len[m++] = ck[j].l;
  46. }
  47. }
  48. for(int j=;j<m;j++)
  49. {
  50. ll res = (ll)ck[i].w*len[j]*(j+);
  51. if(res > ans)
  52. {
  53. ans = res;
  54. answ = ck[i].w;
  55. ansl = len[j];
  56. }
  57. }
  58. }
  59. printf("%I64d\n%d %d\n",ans,answ,ansl);
  60.  
  61. }

CodeForces 589B-Layer Cake-暴力模拟的更多相关文章

  1. CodeForces 589B Layer Cake (暴力)

    题意:给定 n 个矩形是a*b的,问你把每一块都分成一样的,然后全放一块,高度都是1,体积最大是多少. 析:这个题,当时并没有完全读懂题意,而且也不怎么会做,没想到就是一个暴力,先排序,先从大的开始选 ...

  2. CodeForces - 589B(暴力+排序)

    Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n ...

  3. CodeForces - 589B

    题目链接:https://vjudge.net/contest/242578#problem/B Dasha decided to bake a big and tasty layer cake. I ...

  4. 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 ...

  5. bnuoj 20832 Calculating Yuan Fen(暴力模拟)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=20832 [题意]: 给你一串字符串,求一个ST(0<ST<=10000),对字符串中字符 ...

  6. POJ 1013 小水题 暴力模拟

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35774   Accepted: 11 ...

  7. hdu_1006 Tick and Tick(暴力模拟)

    hdu1006 标签(空格分隔): 暴力枚举 好久没有打题了,退队了有好几个月了,从心底不依赖那个人了,原来以为的爱情戏原来都只是我的独角戏.之前的我有时候好希望有个人出现,告诉自己去哪里,做什么,哪 ...

  8. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  9. 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 ...

  10. 美团2018年CodeM大赛-资格赛 分数 暴力模拟

    链接:https://www.nowcoder.com/acm/contest/138/D来源:牛客网 小胖参加了人生中最重要的比赛——MedoC资格赛.MedoC的资格赛由m轮构成,使用常见的“加权 ...

随机推荐

  1. MySQL 8 新特性之自增主键的持久化

    自增主键没有持久化是个比较早的bug,这点从其在官方bug网站的id号也可看出(https://bugs.mysql.com/bug.php?id=199).由Peter Zaitsev(现Perco ...

  2. xadmin的使用

    01-下载源码 GitHub地址:https://github.com/sshwsfc/xadmin # 安装xadmin 由于使用的是Django2.0的版本,所以需要安装xadmin项目djang ...

  3. Python做windows服务

    Python做windows服务(多进程服务),并结束多进程 Python中_,__,__xx__的区别 在注册MyWinService服务时,再使用 "sc delete 服务器名称&qu ...

  4. 007-迅雷定时重启AutoHotkey脚本-20190411

    ;; 定时重启迅雷.ahk,;;~ 2019年04月11日;#SingleInstance,forceSetWorkingDir,%A_ScriptDir%DetectHiddenWindows,On ...

  5. Python入门-格式化输出

    需求:将用户的姓名.年龄.工作.爱好 ,然后打印成以下格式: ------------ Info of Tom ------ Name : Tom Age : 22 Job : Teacher Hob ...

  6. [Offer收割]编程练习赛97

    链接 [https://hihocoder.com/contest/offers97/problems] 题意 题目1 : 放置矩形 时间限制:10000ms 单点时限:1000ms 内存限制:256 ...

  7. Daily Scrum 12.19

    Member Task on 12.19 Task on 12.20 仇栋民 请假 完成Task972 : 完成活动评分基础功能 康家华 完成 Task1004 : 百度map UI优化 完成Task ...

  8. Python2和Python3中urllib库中urlencode的使用注意事项

    前言 在Python中,我们通常使用urllib中的urlencode方法将字典编码,用于提交数据给url等操作,但是在Python2和Python3中urllib模块中所提供的urlencode的包 ...

  9. Python之字符串操作

    一.字符串特点 内容不可修改 password=' #内容不可修改 二.字符串常用方法 1..strip()方法 去字符串两边的空格和换行符 print(password.strip()) #去掉字符 ...

  10. Python爬虫:爬取人人都是产品经理的数据

    爬取内容: 人人都是产品经理首页(www.woshipm.com)左侧[最新文章]下如图样式的文章标题.浏览量和缩略图. 思路: 1. 用BeautifulSoup解析网页 变量名 = Beautif ...