B. Anton and Lines
 

The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = ki·x + bi. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x1 < x2. In other words, is it true that there are1 ≤ i < j ≤ n and x', y', such that:

  • y' = ki * x' + bi, that is, point (x', y') belongs to the line number i;
  • y' = kj * x' + bj, that is, point (x', y') belongs to the line number j;
  • x1 < x' < x2, that is, point (x', y') lies inside the strip bounded by x1 < x2.

You can't leave Anton in trouble, can you? Write a program that solves the given task.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x1 and x2 ( - 1 000 000 ≤ x1 < x2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines.

The following n lines contain integers kibi ( - 1 000 000 ≤ ki, bi ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either ki ≠ kj, or bi ≠ bj.

Output

Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes).

Sample test(s)
input
4
1 2
1 2
1 0
0 1
0 2
output
NO
input
2
1 3
1 0
-1 3
output
YES

题意:给你x,y,还有n条直线,问你在x到y的区域内部是否存在交点,不包括x,y上
题解:贪心,我们知道在x,y上必然存在两个交点,所以我们贪心按照左边从小到大排序,如果右边不是递增的则存在交点
///
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//****************************************
#define maxn 1000000+5
#define mod 1000000007 double k[maxn],b[maxn]; struct ss{ double l;
double r;
int index;
}G[maxn];
int cmp(ss s1,ss s2){
if(s1.l==s2.l)return s1.r<s2.r;
else return s1.l<s2.l;
}
int n;
int main(){ n=read();
double x,y;
scanf("%lf%lf",&x,&y);
int kk=;
for(int i=;i<=n;i++){
scanf("%lf%lf",&k[i],&b[i]);
double xx=k[i]*x+b[i];
double yy=k[i]*y+b[i];
G[++kk].l=xx;G[kk].r=yy;
}
sort(G+,G+kk+,cmp);
double now=-,last=G[].r;
for(int i=;i<=kk;i++){ if(G[i].r<last){
cout<<"YES"<<endl;
return ; }
now=G[i].l;
last=G[i].r;
}
cout<<"NO"<<endl;
return ;
}

代码


Codeforces Round #329 (Div. 2)B. Anton and Lines 贪心的更多相关文章

  1. Codeforces Round #329 (Div. 2) B. Anton and Lines 逆序对

    B. Anton and Lines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/pr ...

  2. Codeforces Round #324 (Div. 2) E. Anton and Ira 贪心

    E. Anton and Ira Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  3. 贪心 Codeforces Round #288 (Div. 2) B. Anton and currency you all know

    题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再 ...

  4. Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心

    Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  5. Codeforces Round #329 (Div. 2)

    推迟了15分钟开始,B卡住不会,最后弃疗,rating只涨一分...   水(暴力枚举) A - 2Char /******************************************** ...

  6. Codeforces Round #404 (Div. 2) D. Anton and School - 2 数学

    D. Anton and School - 2 题目连接: http://codeforces.com/contest/785/problem/D Description As you probabl ...

  7. Codeforces Round #379 (Div. 2) E. Anton and Tree 缩点 直径

    E. Anton and Tree 题目连接: http://codeforces.com/contest/734/problem/E Description Anton is growing a t ...

  8. Codeforces Round #379 (Div. 2) D. Anton and Chess 水题

    D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play ...

  9. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分

    C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is p ...

随机推荐

  1. VMware 12虚拟机下Ubuntu 16连不上网解决方法

    打开自带Firefox浏览器,显示连接不上网,终端下 ping 也显示 unkown   解决方法: 1.打开虚拟机的“编辑”选项,选择“虚拟网络编辑器” 2.选择VMnet8(我不知道为啥VMnet ...

  2. CAD利用Select2得到所有实体(网页版)

    主要用到函数说明: IMxDrawSelectionSet::Select2 构造选择集.详细说明如下: 参数 说明 [in] MCAD_McSelect Mode 构造选择集方式 [in] VARI ...

  3. Ubuntu---vim配置

    1. Linux g++开启C++11支持 1.1 使用vim打开.bashrc文件 sudo vim ~/.bashrc 1.2 在some more ls aliases注释块的地方添加: ali ...

  4. java导出word的6种方式(转发)

    来自: http://www.cnblogs.com/lcngu/p/5247179.html 最近做的项目,需要将一些信息导出到word中.在网上找了好多解决方案,现在将这几天的总结分享一下. 目前 ...

  5. kata练习题

    This time no story, no theory. The examples below show you how to write function accum: Examples: ac ...

  6. circumferential averge streamwise velocity using Tecplot and Matlab

    Input: results from solver output: circumferential averge physical quantities( such as streamwise ve ...

  7. Hdu 5806 NanoApe Loves Sequence Ⅱ(双指针) (C++,Java)

    Hdu 5806 NanoApe Loves Sequence Ⅱ(双指针) Hdu 5806 题意:给出一个数组,求区间第k大的数大于等于m的区间个数 #include<queue> # ...

  8. Spring核心技术(五)——Spring中Bean的作用域

    前文概述了Spring的容器,Bean,以及依赖的一些信息,本文将描述一下Bean的作用域 Bean的作用域 当开发者定义Bean的时候,同时也会定义了该如何创建Bean实例.这些具体创建的过程是很重 ...

  9. 使用 XMLHttpRequest实现Ajax

    [XMLHttpRequest的概述] 1.XMLHttpRequest最早是在IE5中以ActiveX组件的形式实现的.非W3C标准 2.创建XMLHttpRequest对象(由于非标准所以实现方法 ...

  10. linux下git+github个人使用记录

    Linux: 安装git的命令: sudo apt install git 查看版本确认安装成功: git --version 生成密钥: ssh-keygen -t rsa -C "you ...