Official

A - Seats 2 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).


To get straight to the point, the answer is Yes if \(M \le \lceil N / 2 \rceil\), and No otherwise. This is equivalent to \(2M -1 \le N\).

It can be proved as follows:

Assign numbers to the seat, so that each number is assigned to the (two possible) values. (If there is an odd number of seats, assign the last number only once.) The number assigned to the last seat is \(X = \lceil N / 2 \rceil\).

Here, by the condition the seats that have the same number can acomodate at most one person. Thus, if \(X \lt M\), then we cannot seat the people. Conversely, one can seat the \(i\)-th person to seat \(i\) to the left, so that the people sit as oxox ...; this satisfies the requirements.

Sample code in Python:

n, m = map(int, input().split())
print("Yes" if 2 * m - 1 <= n else "No")

Sample code in C++:

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

int main(){
    int n, m; cin >> n >> m;
    cout << (2 * m - 1 <= n ? "Yes" : "No") << endl;
}

posted:
last update: