A - Three-Point Shot Editorial by AnandOza


We could solve this with casework, but instead we can observe that the answer is Yes if and only if the scores are currently less than 3 points apart, so we can use absolute value.

Sample code (C++):

int main() {
    int x, y;
    cin >> x >> y;
 
    bool ans = abs(x - y) < 3;
 
    cout << (ans ? "Yes" : "No") << "\n";
 
    return 0;
}

posted:
last update: