Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7048631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:54:54+00:00 2026-05-28T02:54:54+00:00

The problem goes like this (translated): There are n (n <= 25000) people at

  • 0

The problem goes like this (translated):

There are n (n <= 25000) people at the bottom of a mountain, and everyone wants to go up, then down the mountain. There are 2 tour guides: one for helping a person go up the mountain, one for helping a person go down. Person i takes up(i) time to climb this mountain, and down(i) time to descend it. However, each guide can only help 1 person at a time (which means at most 1 person can be climbing, and at most 1 person can be descending the mountain at any given time). Assume when the “up” guide reaches the top, he gets instantly teleported back to the bottom, as with the “down” guide. Find the least time it takes to get everyone up and back down the mountain. (People can congregate at the top of the mountain if necessary)

Here’s a sample input for the problem, with annotations by me:

3 persons  
person 1: up=6 minutes, down=4 minutes  
person 2: up=8 minutes, down=1 minutes  
person 3: up=2 minutes, down=3 minutes

Output to the input:

Minimum amount of time is 17. This is because If person 3 goes first, then person 1, and then person 2 (and this same order is
used for both the ascent and descent), this gives a total time of 17.

I’ve tried coming up with a few algorithms, but here’s what I have so far:

An O(n! * n) algorithm: just permute the cows through all possible permutations using next_permutation

A greedy algorithm: I’ve sorted the people by decreasing descending time, and tried placing them together, but this did not result in the right solution.

Other thoughts

I’m turning to dynamic programming now, as according to the CLR, optimization problems are usually greedy or dynamic programming (this problem , I think, satisfies optimal substructure).

I’ve noticed that in the minimal solution, the “up” guide will have no rest until everyone is up the mountain. (So no gaps between person 1’s ascent, person 2’s ascent, etc..) Maybe the problem can be reduced to just minimizing the gaps between the descent times?

I’m having trouble picturing a state for this dynamic programming problem, ( I don’t think it’s single dimensional, because I don’t think you can find the optimal solution for i person’s just knowing the optimal solution for i-1 persons).

Could anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:54:55+00:00Added an answer on May 28, 2026 at 2:54 am

    This problem is equivalent to the n-job 2-machine flow shop problem with the makespan objective (n/2/F/Cmax). Johnson’s algorithm finds an exact solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java concurrency problem, it goes like this: There is a Servlet
My Problem goes like this?? I am having a class addEditPatient.m and its Xib
So my problem goes like this, I have two lists LIST A contains. Item
I am facing this issue but unable to resolve. My problem goes like this:
My code goes like this for simple practise problem which i am trying to
My problem goes something like this: HttpWebRequest request; try { request = (HttpWebRequest) WebRequest.Create(url);
Hi the problem goes like this: I have in CoreData entities that have a
I'm having a Hibernate query problem, basically it goes like this ... I have
My problem goes like this :- { someview = [[someview1 alloc]initWithFrame:CGRectMake(0, 0, 1024, 1024))
i have a small problem here which i cannot fix,This post goes through but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.