Statistics

Problem Statement for "Scissors"

Problem Statement

You are in charge of a team of N other people. Together, you are going to prepare decorations for a huge party. In order to do that, each of you needs to have a pair of scissors. You already have one, but none of your helpers do.

You have recently purchased N pairs of scissors from an online retailer. They just arrived, but there is a small issue: each pair of scissors is wrapped in plastic. Getting scissors out of the plastic wrap requires having another pair of scissors (that's not in plastic) and it takes 10 seconds.

Assume that everything other than opening the packages happens instantly. (I.e., whenever a new pair of scissors has been opened, somebody can take it and immediately start opening another box.)

Calculate and return the shortest amount of time (in seconds) in which it is possible to release all the scissors from their plastic wraps.

Definition

Class:
Scissors
Method:
openingTime
Parameters:
int
Returns:
int
Method signature:
int openingTime(int N)
(be sure your method is public)

Constraints

  • N will be between 1 and 10^9, inclusive.

Examples

  1. 3

    Returns: 20

    At the beginning you have the only free pair of scissors. It will take you 10 seconds to open a box containing another pair of scissors. At this point in time you have two pairs of scissors that are free and two that are still in plastic. Both other boxes with scissors can now be opened at the same time: one by you and one by somebody who took the pair of scissors you just liberated.

  2. 10

    Returns: 40

    One possible optimal schedule: First 10 seconds: open one box. You now have 2 scissors free + 9 in boxes. Second 10 seconds: open two boxes. You now have 4 scissors free + 7 in boxes. Third 10 seconds: open two boxes. You now have 6 scissors free + 5 in boxes. Fourth 10 seconds: open the remaining five boxes. There are other ways to open all scissors in 40 seconds but there is no way to do it faster.

  3. 1234

    Returns: 110

  4. 1

    Returns: 10

  5. 2

    Returns: 20

  6. 4

    Returns: 30

  7. 5

    Returns: 30

  8. 6

    Returns: 30

  9. 7

    Returns: 30

  10. 8

    Returns: 40

  11. 9

    Returns: 40

  12. 10

    Returns: 40

  13. 1023

    Returns: 100

  14. 1022

    Returns: 100

  15. 1024

    Returns: 110

  16. 1025

    Returns: 110

  17. 123456789

    Returns: 270

  18. 987654321

    Returns: 300

  19. 1000000000

    Returns: 300

  20. 998977654

    Returns: 300

  21. 989796959

    Returns: 300

  22. 314159265

    Returns: 290

  23. 35897932

    Returns: 260

  24. 111111111

    Returns: 270

  25. 500

    Returns: 90

  26. 50

    Returns: 60

  27. 10000000

    Returns: 240

  28. 99999999

    Returns: 270


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: