Official

A - AtCoder Line Editorial by cn449


初心者の方へ

高橋君は \(X < Y\) のときは上り列車に、\(X > Y\) のときは下り列車に乗車します。

\(X < Y\) のときは \(X < Z < Y\) であることが、\(X > Y\) のときは \(X > Z > Y\) であることが高橋君が乗っている電車が駅 \(Z\) に停車することがあることの必要十分条件となります。

実装例

#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: