Codeforces Round #329 (Div. 2)B. Anton and Lines

题意:给你x,y,还有n条直线,问你在x到y的区域内部是否存在交点,不包括x,y上
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxm=1e5+10;
struct node
{
    double y1,y2;
    bool operator<(const node s)const
    {
        if(y1==s.y1)
            return y2<s.y2;
        else
            return y1<s.y1;
    }
}t[maxm];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        double x1,x2;
        scanf("%lf%lf",&x1,&x2);
        for(int i=0;i<n;i++)
        {
            double k,b;
            scanf("%lf%lf",&k,&b);
            t[i].y1=k*x1+b;
            t[i].y2=k*x2+b;
        }
        sort(t,t+n);
        int ok=0;
        for(int i=0;i<n-1;i++)
        {
            if(t[i].y2>t[i+1].y2)
            {
                ok=1;
                break;
            }
        }
        if(ok)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}


你可能感兴趣的:(Codeforces Round #329 (Div. 2)B. Anton and Lines)