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. myeclipse设置jvm参数的三种方式

    方法一: 打开eclipse,选择Window--Preferences...在对话框左边的树上双击Java,再双击Installed JREs,在右边选择前面有对勾的JRE,再单击右边的“Edit” ...

  2. Python Django 之 MVT

    一.Django的MVT模式 M: Model, 模型 与MVC中的M相同,负责对数据的处理 V: View, 视图 与MVC中的C类似,负责处理用户请求,调用M和T,响应请求 T: Template ...

  3. dom4j+XPath

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...

  4. 多重条件判断SQL:用于用户名称,密码,权限的检测和判断

    string sqlstr = "select count(*) from tb_admin where 用户名='"+UserName+"'and 密码='" ...

  5. how to get keyboard key with non blocking in terminal

    /************************************************************************** * how to get keyboard ke ...

  6. 【linux】wifi不能使用的问题

    Worked solution (Requirements: kernel >=4.11) : Download driver directory from this repo:https:// ...

  7. 安装依赖库的方法-linux

    前言 使用linux系统的过程中,项目可能需要用到各种依赖库或者工具包,本文对库或者包的安装方法进行概述. 具体方法 如何安装各种依赖库或者工具包:1)直接使用apt-get install进行安装, ...

  8. QT-This application failed to start because it could not find or load the Qt platform plugin "windows"

    前言 将qt的vs工程生成Release版本,不过出现错误,现将可以解决该问题的方法记录下来. 项目环境 系统:win7_64 软件:VS2013.QT5.6.2.qt-vs-addin-1.2.5 ...

  9. HihoCoder - 1886 :中位数2(贪心)

    描述 对于一个长度为n的数列A,我们如下定义A的中位数med(A): 当n是奇数时,A的中位数是第(n+1)/2大的数:当n是偶数时,A的中位数是第n/2大的数和第n/2+1大的数的平均值. 同时,我 ...

  10. vue 钩子

    生命周期总结 这么多钩子函数,我们怎么用呢,我想大家可能有这样的疑问吧,我也有,哈哈哈. beforecreate : 举个栗子:可以在这加个loading事件 created :在这结束loadin ...