Official

A - 2UP3DOWN Editorial by en_translator


If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).


When Takahashi is at \(X\)-th floor, he uses stairs if he is heading at between the \((X-3)\)-th and \((X+2)\)-th floor. All that left is to determine if \(Y\) is in this range.

Sample code (Python)

X,Y = map(int,input().split())
if X-3<=Y<=X+2:
  print("Yes")
else:
  print("No")

Sample code (C++)

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

int main(){
  int x,y;
  cin >> x >> y;
  if(x-3<=y && y<=x+2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

posted:
last update: