Official

A - Median? Editorial by en_translator


It is sufficient to check if \(b\) comes in the second place when \(a, b\), and \(c\) are sorted in the increasing order.

The answer is Yes if \(a \leq b \leq c\) or \(a \geq b \geq c\), and No otherwise.

Sample code (C++):

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a <= b and b <= c) or (a >= b and b >= c)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Sample code (Python) :

a, b, c = map(int, input().split())
print("Yes" if a <= b <= c or a >= b >= c else "No")

posted:
last update: