Three Numbers in Nondecreasing Order
Programming Basics · C++
TASK
Problem
Given three integers `a`, `b`, and `c`, print `YES` if `a ≤ b ≤ c`; otherwise print `NO`.
EXAMPLE
Example
1 2 3
YES
LIMITS
Constraints
|a|, |b|, |c| ≤ 10^9.
LEARN
Theory for this problem
+
These exercises combine arithmetic, comparisons, and small branches. Keep each condition explicit and easy to verify.
Connection to “Three Numbers in Nondecreasing Order”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.
NEED HELP?
Hints
+
['Break the task into a few simple checks instead of compressing everything into a clever expression.', 'After solving “Three Numbers in Nondecreasing Order”, 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>
using namespace std;
int main() {
long long a,b,c;
cin >> a >> b >> c;
cout << (a<=b&&b<=c?"YES":"NO") << '\n';
return 0;
}