谷歌店面

There are n post offices in a row, You are given the distance of each post office from your home. A post office can send a post to another post office if the distance between the two places is less than or equal to x. You are given q queries. Each query contain indices of two post offices. You have to find whether the post offices can deliver post to each other or not. You may use any number of post offices between two post offices if they satisfy the distance criteria
Expected time complexity= O(n+q)