PROBLEM LINK:
Author: Chahak Gupta
Tester: Rahul Johari
DIFFICULTY:
EASY.
PREREQUISITES:
Sorting
EXPLANATION:
Note that the number of unlucky tiles ≤ 3000. Chahak can reach tile number n if the first and the last tiles are not unlucky and there are not three or more unlucky tiles in a row. So let sort the array of unlucky tiles and go through it, checking for three or more consecutive unlucky tiles. Also one needs to check if the first or the last tile is in this array are lucky.
AUTHOR’S AND TESTER’S SOLUTIONS:
Author’s solution can be found here.