Alice just invited Bob to come over for dinner at her place. Bob is not dressed properly and he does not wish to take any chances, so he wants to rush to an apartment of one of his N friends, change there and meet Alice for the dinner.
Alice and Bob's friends live in a skyscraper with many floors. Alice lives on the a-th floor, the apartments of Bob's friends are located on the floors F1,F2,…,FN and Bob is initially at the b-th floor. It takes exactly 1 minute to go one floor up or down from each floor.
Bob needs exactly c minutes to change in any of his friends' apartments. Find the minimum time he needs to go to one of his friends' apartments, change and get to Alice's apartment.
This is a(n):
Details:
Alice just invited Bob to come over for dinner at her place. Bob is not dressed properly and he does not wish to take any chances, so he wants to rush to an apartment of one of his N friends, change there and meet Alice for the dinner.
Alice and Bob's friends live in a skyscraper with many floors. Alice lives on the a-th floor, the apartments of Bob's friends are located on the floors F1,F2,…,FN and Bob is initially at the b-th floor. It takes exactly 1 minute to go one floor up or down from each floor.
Bob needs exactly c minutes to change in any of his friends' apartments. Find the minimum time he needs to go to one of his friends' apartments, change and get to Alice's apartment.