Official
A - On and Off Editorial by en_translator
When \(S \lt T\), the answer is Yes
if \(S \leq X \lt T\), or otherwise No
.
When \(T \lt S\), the answer is Yes
if \(X \lt T\) or \(S \leq X\), or otherwise No
.
We can implement them with if statements as follows.
Sample code (C++) :
#include <bits/stdc++.h>
using namespace std;
int main() {
int s, t, x;
cin >> s >> t >> x;
if (s < t) {
cout << (s <= x and x < t ? "Yes" : "No") << '\n';
} else {
cout << (x < t or s <= x ? "Yes" : "No") << '\n';
}
}
Sample code (Python) :
s, t, x = map(int, input().split())
if s < t:
print("Yes" if s <= x < t else "No")
else:
print("Yes" if x < t or s <= x else "No")
posted:
last update: