Description

给定一个n个点的严格凸多边形(各个内角<180°),现在要切出两个非退化三角形(三点不共线),要求两个三角形顶点必须是凸多边形的顶点,且三角形不可相交(但是点或边可以重合)。求两个三角形面积之差的最大值。

Input

第一行,一个整数N。
第二到N+1行,每行两个整数xi,yi,表示多边形的一个点,保证顶点按顺时针或逆时针顺序给出。

Output

输出答案,精确到小数点后1位。
最小三角形一定是相邻三点构成,因此只需枚举每个最小三角形,查询剩余部分中的最大三角形
dp,f[a][b]表示三角形一条边从a到b的,另一个顶点c在a到b之间的最大面积,固定a,令b递增则决策点c可以线性求出
辅助g[a][b]=max(g[a][b-1],g[a+1][b],f[a][b])可支持查询
#include<bits/stdc++.h>
typedef long long i64;
struct pos{int x,y;}ps[];
pos operator+(pos a,pos b){return (pos){a.x+b.x,a.y+b.y};}
pos operator-(pos a,pos b){return (pos){a.x-b.x,a.y-b.y};}
i64 operator*(pos a,pos b){return i64(a.x)*b.y-i64(a.y)*b.x;}
int n,ws[];
i64 ans=,s0[],ms[];
void maxs(i64&a,i64 b){if(a<b)a=b;}
int main(){
scanf("%d",&n);
for(int i=;i<=n;++i)scanf("%d%d",&ps[i].x,&ps[i].y);
if((ps[]-ps[])*(ps[]-ps[])<)std::reverse(ps+,ps+n+);
ps[n*+]=ps[];
ps[]=ps[n];
for(int i=;i<=n;++i)ps[n+i]=ps[i],ws[i]=i;
for(int d=;d<n;++d){
for(int l=,r=d;l<=n;++l,++r){
pos a=ps[r]-ps[l];
s0[l]=(ps[ws[l]]-ps[l])*a;
while(ws[l]+<r){
i64 s1=(ps[ws[l]+]-ps[l])*a;
if(s1<s0[l])break;
++ws[l];
s0[l]=s1;
}
maxs(ms[l],s0[l]);
}
ms[n+]=ms[];
for(int l=;l<=n;++l)maxs(ms[l],ms[l+]);
}
for(int l=,r=n-;l<=n;++l,++r)maxs(ans,ms[l]-(ps[r]-ps[l])*(ps[r+]-ps[l]));
printf("%lld.%lld\n",ans/,ans%*);
return ;
}

bzoj4232: [Neerc2011 Northern]Kids Like Cakes的更多相关文章

  1. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  2. 2632: [neerc2011]Gcd guessing game

    2632: [neerc2011]Gcd guessing game Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 144  Solved: 84[S ...

  3. 【2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D】---暑假三校训练

    2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D Problem D. Distribution in Metagonia Input ...

  4. SGU 495. Kids and Prizes

    水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...

  5. Kids and Prizes(SGU 495)

    495. Kids and Prizes Time limit per test: 0.25 second(s)Memory limit: 262144 kilobytes input: standa ...

  6. sgu 495. Kids and Prizes (简单概率dp 正推求期望)

    题目链接 495. Kids and Prizes Time limit per test: 0.25 second(s)Memory limit: 262144 kilobytes input: s ...

  7. 495. Kids and Prizes

    http://acm.sgu.ru/problem.php?contest=0&problem=495 学习:当一条路走不通,换一种对象考虑,还有考虑对立面. 495. Kids and Pr ...

  8. northern truck 是什么牌子?具体_百度知道

    northern truck 是什么牌子?具体_百度知道 northern truck 是什么牌子?具体

  9. SGU 495. Kids and Prizes( 数学期望 )

    题意: N个礼品箱, 每个礼品箱内的礼品只有第一个抽到的人能拿到. M个小孩每个人依次随机抽取一个,  求送出礼品数量的期望值. 1 ≤ N, M ≤ 100, 000 挺水的说..设f(x)表示前x ...

随机推荐

  1. Java——文件过滤器

    body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...

  2. 玩转X-CTR100 | X-Assistant串口助手控制功能

      更多塔克创新资讯欢迎登陆[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ]       X-CTR100控制器配套的X-Assistant串口调试 ...

  3. MyEclipse持续性开发教程:用JPA和Spring管理数据(二)

    MyEclipse红运年货节 在线购买低至69折!火爆开抢>> [MyEclipse最新版下载] 本教程介绍了MyEclipse中的一些基于JPA / Spring的功能.有关设置JPA项 ...

  4. JSP--TOMCAT-MYSQL web页面查询

    queryStudent.jsp代码如下 <%@ page language="java" contentType="text/html; charset=gb23 ...

  5. PHP出现Cannot modify header information问题的解决方法

    在C盘的WINDOWS中找到php.ini 这个配置文件,然后查找一项:output_buffering将其值由原来的off改为on,重新启动Apache就ok了.

  6. PHP文件上传大小设置

    PHP.INI配置:文件上传功能配置教程 打开php.ini配置文件中的upload_tmp_dir.upload_max_filesize.post_max_size等选项. php.ini中文件上 ...

  7. ASCII编码和Unicode编码的区别

    链接: 计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.Unicode把所有语言都统一到一套编码里,这样就不会再有乱码问题了.Unicode标准也在不断发展,但最常用的是用两个字 ...

  8. linux中grep用法(“或”、“与”)

    1.普通用法 grep keyword 若果keyword中有空格 grep "keyword" 例如: ls | grep mp4 2.“与”操作(其实就是多次筛选) grep ...

  9. 了解 .NET 的默认 TaskScheduler 和线程池(ThreadPool)设置,避免让 Task.Run 的性能急剧降低

    .NET Framework 4.5 开始引入 Task.Run,它可以很方便的帮助我们使用 async / await 语法,同时还使用线程池来帮助我们管理线程.以至于我们编写异步代码可以像编写同步 ...

  10. Codeforces Beta Round #81 A Transmigration

    在魔界战记中有一个设定叫做转生,当一个人物转生时,会保留之前的技能,但是技能等级需要乘以一个系数 k ,如果技能等级小于100,将会在转生之后失去该技能. 转生之后,会学到一些新技能.这些新技能附加的 ...