OpenGenus / cosmos

World's largest Contributor driven code dataset | Used in Quark Search Engine, @OpenGenus IQ, OpenGenus Visual Project
http://internship.opengenus.org
GNU General Public License v3.0
13.56k stars 3.68k forks source link

solution to codechef problem BFRIEND in C++ #4971

Open Ankit152 opened 4 years ago

Ankit152 commented 4 years ago

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.

Ankit152 commented 4 years ago

please assign this issue to me and please review my PR #4806