PROBLEM 73
Medium

Same Half-Plane by X

Programming Basics · C++

</>
STATUS Not solved

TASK

Problem

#73

In “Same Half-Plane by X”, solve the stated coordinate or interval relation using integer comparisons.

EXAMPLE

Example

Input
0 5
Output
NO

LIMITS

Constraints

Coordinate magnitudes are at most 10^9; interval endpoints are given in nondecreasing order.
📖
LEARN Theory for this problem
+

Coordinate tasks often reduce to comparisons, absolute differences, `min`, and `max`.

Connection to “Same Half-Plane by X”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.

💡
NEED HELP? Hints
+

['Translate the geometry into inequalities before coding.', 'After solving “Same Half-Plane by X”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']

ANSWER Solution
+
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main() {
    long long x1, x2;
    cin >> x1 >> x2;
    cout << ((x1 * x2 > 0) ? "YES" : "NO") << '\n';
    return 0;
}