Official

A - AtCoder Line Editorial by en_translator


For beginners

Takahashi takes an inbound train if \(X < Y\) and an outbound train if \(X > Y\).

Takahashi’s train will stop at station \(Z\) if and only if \(X < Z < Y\) if \(X < Y\), and \(X > Z > Y\) if \(X > Y\).

Sample code

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

int main() {
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    if (x < z && z < y) cout << "Yes\n";
    else if (y < z && z < x) cout << "Yes\n";
    else cout << "No\n";
}

posted:
last update: