Statistics

Problem Statement for "MissedCall"

Problem Statement

Victor has bought a new album from his favorite group. The album contains N songs that are each songDuration seconds long. There's 5 seconds of silence between each pair of consecutive songs. At time 0, Victor starts listening to the album, and at that exact moment, his phone starts to ring. The phone rings every delay seconds, and each ring lasts 1 second (for example, for delay = 3, the phone will ring during the seconds 0, 3, 6 and so on). He cannot hear the rings while the music is playing because the volume is too loud. He can only hear rings during the silent intervals between songs. If a ring starts at the same moment that a song starts playing, he will not hear it. Similarly, if a ring stops at the same moment that a song stops playing, he will not hear it. The album will play exactly once, so after the last song ends, Victor will be able to hear the phone again. Return the time in seconds at which Victor will first hear the phone ring.

Definition

Class:
MissedCall
Method:
waitingTime
Parameters:
int, int, int
Returns:
int
Method signature:
int waitingTime(int N, int songDuration, int delay)
(be sure your method is public)

Constraints

  • N will between 1 and 20, inclusive.
  • songDuration will between 1 and 180, inclusive.
  • delay will between 1 and 20, inclusive.

Examples

  1. 2

    5

    7

    Returns: 7

    Second 0: The first song starts playing, and the telephone rings. Second 1-4: The first song is playing. Second 5-6: Silence. Second 7: The telephone rings. Victor only misses the first ring.

  2. 4

    5

    20

    Returns: 40

    Victor will not hear the phone until after the album ends.

  3. 20

    5

    20

    Returns: 200

  4. 6

    9

    20

    Returns: 40

    Second 0: The first song starts playing, and the telephone rings. Second 1-8: The first song is playing. Second 9-13: Silence. Second 14-19: The second song is playing. Second 20: The second song is playing, and the telephone rings. Second 21-22: The second song is playing. Second 23-27: Silence. Second 28-36: The third song is playing. Second 37-39: Silence. Second 40: The telephone rings. Victor misses the first two rings.

  5. 1

    10

    1

    Returns: 10

  6. 1

    10

    2

    Returns: 10

  7. 1

    11

    2

    Returns: 12

  8. 2

    10

    1

    Returns: 10

  9. 2

    10

    2

    Returns: 10

  10. 2

    11

    2

    Returns: 12

  11. 3

    10

    2

    Returns: 10

  12. 3

    11

    2

    Returns: 12

  13. 20

    65

    8

    Returns: 136

  14. 1

    66

    8

    Returns: 72

  15. 7

    73

    8

    Returns: 152

  16. 14

    74

    8

    Returns: 232

  17. 20

    81

    8

    Returns: 168

  18. 20

    82

    8

    Returns: 256

  19. 18

    89

    8

    Returns: 184

  20. 11

    90

    8

    Returns: 280

  21. 13

    117

    5

    Returns: 120

  22. 1

    15

    20

    Returns: 20

  23. 2

    109

    3

    Returns: 111

  24. 11

    18

    20

    Returns: 20

  25. 12

    84

    14

    Returns: 84

  26. 18

    174

    4

    Returns: 176

  27. 18

    86

    9

    Returns: 90

  28. 11

    149

    19

    Returns: 152

  29. 4

    111

    2

    Returns: 112

  30. 2

    28

    10

    Returns: 30

  31. 15

    17

    7

    Returns: 21

  32. 3

    3

    8

    Returns: 24

  33. 20

    4

    9

    Returns: 180

  34. 20

    79

    18

    Returns: 1692

  35. 1

    55

    20

    Returns: 60

  36. 1

    65

    20

    Returns: 80

  37. 13

    61

    18

    Returns: 864

  38. 3

    37

    6

    Returns: 126

  39. 6

    100

    15

    Returns: 630

  40. 3

    71

    19

    Returns: 228

  41. 17

    11

    17

    Returns: 187

  42. 11

    28

    17

    Returns: 374

  43. 11

    45

    17

    Returns: 561

  44. 2

    62

    17

    Returns: 136

  45. 20

    79

    17

    Returns: 1003

  46. 20

    96

    17

    Returns: 1207

  47. 2

    113

    17

    Returns: 238

  48. 6

    130

    17

    Returns: 816

  49. 20

    147

    17

    Returns: 1819

  50. 14

    164

    17

    Returns: 2023

  51. 20

    12

    18

    Returns: 216

  52. 20

    30

    18

    Returns: 450

  53. 20

    48

    18

    Returns: 684

  54. 20

    66

    18

    Returns: 918

  55. 17

    84

    18

    Returns: 1152

  56. 20

    102

    18

    Returns: 1386

  57. 20

    120

    18

    Returns: 1620

  58. 20

    138

    18

    Returns: 1854

  59. 20

    156

    18

    Returns: 2088

  60. 20

    174

    18

    Returns: 2322

  61. 2

    13

    19

    Returns: 38

  62. 20

    32

    19

    Returns: 513

  63. 20

    51

    19

    Returns: 779

  64. 20

    70

    19

    Returns: 1045

  65. 20

    89

    19

    Returns: 1311

  66. 3

    108

    19

    Returns: 342

  67. 20

    127

    19

    Returns: 1843

  68. 20

    146

    19

    Returns: 2109

  69. 20

    165

    19

    Returns: 2375

  70. 20

    14

    20

    Returns: 280

  71. 20

    34

    20

    Returns: 580

  72. 8

    54

    20

    Returns: 480

  73. 15

    74

    20

    Returns: 1180

  74. 20

    94

    20

    Returns: 1480

  75. 20

    114

    20

    Returns: 1780

  76. 20

    134

    20

    Returns: 2080

  77. 20

    154

    20

    Returns: 2380

  78. 20

    174

    20

    Returns: 2680

  79. 20

    1

    7

    Returns: 7

  80. 20

    8

    7

    Returns: 21

  81. 20

    15

    7

    Returns: 35

  82. 10

    22

    7

    Returns: 49

  83. 20

    29

    7

    Returns: 63

  84. 1

    36

    7

    Returns: 42

  85. 20

    43

    7

    Returns: 91

  86. 1

    50

    7

    Returns: 56

  87. 14

    57

    7

    Returns: 119

  88. 20

    64

    7

    Returns: 133

  89. 20

    71

    7

    Returns: 147

  90. 20

    78

    7

    Returns: 161

  91. 20

    85

    7

    Returns: 175

  92. 13

    92

    7

    Returns: 189

  93. 5

    99

    7

    Returns: 203

  94. 7

    106

    7

    Returns: 217

  95. 20

    113

    7

    Returns: 231

  96. 9

    120

    7

    Returns: 245

  97. 3

    127

    7

    Returns: 259

  98. 20

    134

    7

    Returns: 273

  99. 1

    141

    7

    Returns: 147

  100. 13

    148

    7

    Returns: 301

  101. 20

    155

    7

    Returns: 315

  102. 20

    162

    7

    Returns: 329

  103. 20

    169

    7

    Returns: 343

  104. 20

    176

    7

    Returns: 357

  105. 20

    1

    8

    Returns: 8

  106. 4

    2

    8

    Returns: 16

  107. 16

    9

    8

    Returns: 24

  108. 20

    10

    8

    Returns: 40

  109. 20

    17

    8

    Returns: 40

  110. 14

    18

    8

    Returns: 64

  111. 20

    25

    8

    Returns: 56

  112. 10

    26

    8

    Returns: 88

  113. 20

    33

    8

    Returns: 72

  114. 2

    34

    8

    Returns: 80

  115. 14

    41

    8

    Returns: 88

  116. 6

    42

    8

    Returns: 136

  117. 20

    49

    8

    Returns: 104

  118. 14

    50

    8

    Returns: 160

  119. 20

    57

    8

    Returns: 120

  120. 20

    58

    8

    Returns: 184

  121. 1

    1

    19

    Returns: 19

  122. 3

    5

    5

    Returns: 5

  123. 5

    5

    5

    Returns: 5

  124. 2

    7

    2

    Returns: 8

  125. 2

    5

    10

    Returns: 20

  126. 1

    1

    1

    Returns: 1

  127. 1

    1

    20

    Returns: 20

  128. 2

    5

    5

    Returns: 5

  129. 1

    5

    5

    Returns: 5

  130. 1

    3

    10

    Returns: 10

  131. 19

    177

    17

    Returns: 544

  132. 20

    180

    20

    Returns: 180

  133. 2

    2

    20

    Returns: 20

  134. 2

    4

    4

    Returns: 4

  135. 2

    1

    20

    Returns: 20


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: