CodeForces Round#549 U2

各点を考慮すると、bx + c> = yx x
は、点{x、yx
x}の上の左側に直線があり、上部の凸状の船体を維持するだけです。

#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const  ll inf  = 0x3f3f3f3f3f3f3f3f;
const int mod  = 998244353;
const int maxn = 1e6 + 4;
const int N    = 5e3 + 5;
const double eps = 1e-6;
const double pi = acos(-1.0);
ll qpow(ll x,ll y,ll mod){
    
    ll ans=1;x%=mod;while(y){
    
     if(y&1) ans=ans*x%mod; x=x*x%mod; y>>=1;}return ans;}


int n,top=1;
struct Point{
    
    ll x,y;}a[maxn];
Point operator + (Point a, Point b) {
    
    return (Point) {
    
    a.x+b.x,a.y+b.y}; }
Point operator - (Point a, Point b) {
    
    return (Point) {
    
    a.x-b.x,a.y-b.y}; }
Point operator * (Point a, ll b) {
    
    return (Point) {
    
    a.x*b,a.y*b}; }
ll operator * (Point a, Point b) {
    
    return a.x*b.y-a.y*b.x; }
bool operator < (Point a, Point b) {
    
    
    if(a.x!=b.x) return a.x<b.x;
    return a.y<b.y;
}
int main() {
    
    
    //freopen("RACE input.in","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
    
    
        scanf("%lld%lld",&a[i].x,&a[i].y);
        a[i].y=a[i].y-a[i].x*a[i].x;
    }
    sort(a+1,a+1+n);
    for(int i=2;i<=n;i++) {
    
    
        if(a[top].x==a[i].x) top--;
        while(top>=2&&(a[top]-a[top-1])*(a[i]-a[top-1])>=0) top--;
        a[++top]=a[i];
    }
    printf("%d\n",top-1);
}

おすすめ

転載: blog.csdn.net/qq_43914084/article/details/106790871