Dilhan's Computing Contest 1 P1 - The Cathedral of Learning

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 1G

Author:
Problem type

Alice and Bob have scheduled a meeting inside of the Cathedral of Learning. Unfortunately, they didn't decide what floor to meet on!

The Cathedral of Learning has N floors. Alice will start on floor a and Bob will start on floor b. The two will then employ opposing strategies to try and find the other: Every minute Alice and Bob will each explore the floor they are on, and will find each other if they are on the same floor. At the end of the minute Alice will take an elevator one floor up, and simultaneously Bob will take an elevator one floor down. They will repeat this process until either they meet up or one of the two can no longer continue the process (i.e. Alice finishes exploring floor N or Bob finishes exploring floor 1) in which case they will leave the building and agree to meet up at a later time.

Given N, a, and b determine if Alice and Bob will successfully meet up within the Cathedral of Learning.

Constraints

1 \leq N \leq 10^{12}

1 \leq a, b \leq N

Subtask 1 [60%]

1 \leq N \leq 100

Subtask 2 [40%]

No additional constraints.

Input Specification

The first line contains the integer N.

The second line contains the integer a.

The third line contains the integer b.

Output Specification

On a single line output the string YES or the string NO - corresponding to whether Alice and Bob will meet in the given scenario.

Sample Input 1

5
3
4

Sample Output 1

NO

Explanation for Sample Output 1

In the first minute Alice will explore floor 3 and Bob will explore floor 4 - they will not meet.
Alice will then take the elevator to floor 4 while simultaneously Bob takes the elevator to floor 3.
In the second minute Alice will explore floor 4 and Bob will explore floor 3 - they will not meet.
Alice will then take the elevator to floor 5 while simultaneously Bob takes the elevator to floor 2.
In the third minute Alice will explore floor 5 and Bob will explore floor 2 - they will not meet.
Alice has now explored the top floor and will then leave the cathedral - Alice and Bob will not meet in the cathedral.

Sample Input 2

10
4
4

Sample Output 2

YES

Sample Input 3

12345
1
12345

Sample Output 3

YES

Sample Input 4

12345
12345
1

Sample Output 4

NO

Comments

There are no comments at the moment.