Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. Problem I: Passage
  2. Time Limit: 8 seconds per test
  3. A team of Byteholers has set out on a trip into Bytemountains. Unfortunately they have caused
  4. an avalanche and now have to escape it. There is an old cable-bridge over a chasm ahead of
  5. them. They have to cross the bridge as quickly as possible. The Byteholers are intimate friends
  6. and therefore have decided that either all or none of them shall survive.
  7. The bridge is old and worn-out, so it won't withstand a great weight. The total weight of
  8. Byteholers on the bridge at any time cannot exceed some limit. Furthermore it is a cable-bridge,
  9. so the Byteholers have to cross it in groups. Next group may enter it only after the previous one
  10. has left.
  11. It is known how much time each Byteholer needs to cross the bridge. A crossing time of a group
  12. is the crossing time of the slowest member of the group. Total crossing time of all Byteholers is
  13. the sum of crossing times of all groups. Obviously it depends on the manner in which they split
  14. into groups.
  15. Be their saviour! Calculate the minimal crossing time of all the Byteholers.
  16. Task
  17. Write a programme that:
  18. • reads the description of the bridge and Byteholers from standard input,
  19. • determines the minimal total crossing time of all Byteholers,
  20. • writes the determined time to the standard output.
  21. Input
  22. The first line of the standard input contains two integers separated by a single space: - defining
  23. the maximal weight allowed for the bridge ( ) and - the number of Byteholers (
  24. ). In each of the following lines there are two integers separated by a single space,
  25. describing successive Byteholers: - the time needed by the Byteholer to cross the bridge (
  26. ) and - the weight of the Byteholer ( ).
  27. Output
  28. Your programme should write a single integer in the first and only output line. The integer
  29. should denote the minimal total crossing time of all Byteholers.
  30. Example
  31. For the input data:
  32. 100 3
  33. 24 60
  34. 10 40
  35. 18 50
  36. the correct result is:
  37. 42
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement