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 ;
}

代码


最新文章

  1. Spring 设值注入 构造注入 p命名空间注入
  2. 2016 daily
  3. Android自定义属性
  4. oracle plsql 捕获异常和抛出异常
  5. Centos rsync+inotify 实现数据同步备份
  6. 动画---图形图像与动画(三)Animation效果的XML实现
  7. Javascript正则表达式笔记
  8. Retrofit2 简介 语法 案例
  9. C# 同步/并发队列ConcurrentQueue (表示线程安全的先进先出 (FIFO) 集合)
  10. java 非缓冲与缓冲数据写入比较
  11. EclipseAndroid打包签名发布安装失败闪退运行不了
  12. SpringMVC model 多余字段 忽略
  13. /usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn&#39;t match a supported version! RequestsDependencyWarning)
  14. Dapper-小型ORM之王(C#.NET)
  15. python全栈开发 * 13知识点汇总 * 180619
  16. python接口自动化测试十六:unittest完成用例
  17. 洛谷P3354 Riv河流 [IOI2005] 树型dp
  18. 生产环境nginx上传文件报错413 Request Entity Too Large
  19. VMWare Workstation 11的安装
  20. .5-浅析express源码之Router模块(1)-默认中间件

热门文章

  1. 部署bugzilla(bugzilla+apache+mysql+linux)
  2. UI设计四要素
  3. 导出功能在数据库内容为数字,excel表格中是汉字的时候
  4. CAD得到当前选择的实体(网页版)
  5. pringboot开启找回Run Dashboard
  6. svn更新报错Please execute the &#39;Cleanup&#39; command.
  7. cmd杀死进程
  8. 版本优化-test
  9. this与const
  10. orcad中注意的事情