900AFind Extra One

来源:互联网 发布:凤凰新闻软件下载 编辑:程序博客网 时间:2024/05/22 08:14

A. Find Extra One
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.

Input

The first line contains a single positive integer n (2 ≤ n ≤ 105).

The following n lines contain coordinates of the points. The i-th of these lines contains two single integers xi and yi (|xi|, |yi| ≤ 109xi ≠ 0). No two points coincide.

Output

Print "Yes" if there is such a point, "No" — otherwise.

You can print every letter in any case (upper or lower).

Examples
input
31 1-1 -12 -1
output
Yes
input
41 12 2-1 1-2 2
output
No
input
31 22 14 60
output
Yes
Note

In the first example the second point can be removed.

In the second example there is no suitable for the condition point.

In the third example any point can be removed.


题意:在坐标系中,给你n个点的坐标,让你去掉一个点,如果这些点能够在y轴同一侧,就输出Yes,否则就输出No。

题解:主要判断横坐标>0和小于0的个数。如果两个个数

#include<bits/stdc++.h>using namespace std;int main(){    int n,cnt1,cnt2,x,y;    while(cin>>n)    {        cnt1=cnt2=0;        for(int i=0; i<n; i++)        {            cin>>x>>y;            if(x>0)                cnt1++;            else cnt2++;        }        if(cnt1>1&&cnt2>1)            puts("No");        else            puts("Yes");    }    return 0;}

都大于1,肯定不行的,其余情况就输出是可以的。

原创粉丝点击