CF1142C U2

题目链接:洛谷 codeforces


$y>x^2+bx+c$也就是$y-x^2>bx+c$

左边是点,右边是直线.

维护上凸包.

虽然这么简单但就是做不出来。

 #include<cstdio>
#include<algorithm>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = ;
struct Point {
LL x, y;
inline Point(LL _x = , LL _y = ): x(_x), y(_y){}
inline Point operator - (const Point &o) const {return Point(x - o.x, y - o.y);}
inline LL operator * (const Point &o) const {return x * o.y - y * o.x;}
inline bool operator < (const Point &o) const {return x < o.x || x == o.x && y > o.y;}
} p[N], q[N], stk[N];
int n, m, top;
int main(){
scanf("%d", &n);
for(Rint i = ;i <= n;i ++){
scanf("%I64d %I64d", &p[i].x, &p[i].y);
p[i].y -= p[i].x * p[i].x;
}
sort(p + , p + n + );
q[m = ] = p[];
for(Rint i = ;i <= n;i ++) if(p[i].x != p[i - ].x) q[++ m] = p[i];
for(Rint i = ;i <= m;i ++){
while(top > && (stk[top] - stk[top - ]) * (q[i] - stk[top - ]) >= ) -- top;
stk[++ top] = q[i];
}
printf("%d\n", top - );
} // nantf tai qiang le!

CF1142C

上一篇:asp.net中处理程序调用HttpContext.Current.Session获取值出错


下一篇:个人博客Week3——案例分析