Official
A - On and Off Editorial by KoD
\(S \lt T\) のとき、\(S \leq X \lt T\) ならば答えは Yes
であり、そうでなければ No
です。
\(T \lt S\) のとき、\(X \lt T\) または \(S \leq X\) ならば答えは Yes
であり、そうでなければ No
です。
以上を if などを用いて実装すると以下のようになります。
実装例 (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';
}
}
実装例 (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: