Statistics

Problem Statement for "DeerInZooDivTwo"

Problem Statement

Brus and Gogo came to the zoo today. It's the season when deer shed their antlers. There are N deer in the zoo. Initially, each deer had exactly two antlers, but since then some deer may have lost one or both antlers. (Now there may be some deer with two antlers, some with one, and some with no antlers at all.)

Brus and Gogo went through the deer enclosure and they collected all the antlers already lost by the deer. The deer have lost exactly K antlers in total. Brus and Gogo are now trying to calculate how many deer have not lost any antlers yet.

Return a int[] with exactly two elements {x,y}, where x is the smallest possible number of deer that still have two antlers, and y is the largest possible number of those deer.

Definition

Class:
DeerInZooDivTwo
Method:
getminmax
Parameters:
int, int
Returns:
int[]
Method signature:
int[] getminmax(int N, int K)
(be sure your method is public)

Constraints

  • N will be between 1 and 1000, inclusive.
  • K will be between 0 and 2N, inclusive.

Examples

  1. 1

    0

    Returns: {1, 1 }

  2. 1

    1

    Returns: {0, 0 }

  3. 1

    2

    Returns: {0, 0 }

  4. 2

    0

    Returns: {2, 2 }

  5. 2

    1

    Returns: {1, 1 }

  6. 2

    2

    Returns: {0, 1 }

  7. 2

    3

    Returns: {0, 0 }

  8. 2

    4

    Returns: {0, 0 }

  9. 3

    0

    Returns: {3, 3 }

  10. 3

    1

    Returns: {2, 2 }

  11. 3

    2

    Returns: {1, 2 }

    There are two possibilities: Either the K=2 antlers come from two different deer, or they come from the same deer. In the first case, there is 1 deer with two antlers (and two other with one antler each), in the second case there are 2 deer with two antlers each (and one deer with none).

  12. 3

    3

    Returns: {0, 1 }

  13. 3

    4

    Returns: {0, 1 }

  14. 3

    5

    Returns: {0, 0 }

  15. 3

    6

    Returns: {0, 0 }

  16. 10

    0

    Returns: {10, 10 }

    All deer still have 2 horns.

  17. 519

    345

    Returns: {174, 346 }

  18. 942

    1427

    Returns: {0, 228 }

  19. 958

    1267

    Returns: {0, 324 }

  20. 975

    49

    Returns: {926, 950 }

  21. 267

    271

    Returns: {0, 131 }

  22. 337

    325

    Returns: {12, 174 }

  23. 796

    1589

    Returns: {0, 1 }

  24. 683

    250

    Returns: {433, 558 }

  25. 566

    403

    Returns: {163, 364 }

  26. 172

    91

    Returns: {81, 126 }

  27. 370

    393

    Returns: {0, 173 }

  28. 915

    1104

    Returns: {0, 363 }

  29. 912

    1711

    Returns: {0, 56 }

  30. 68

    77

    Returns: {0, 29 }

  31. 778

    697

    Returns: {81, 429 }

  32. 106

    76

    Returns: {30, 68 }

  33. 142

    160

    Returns: {0, 62 }

  34. 301

    275

    Returns: {26, 163 }

  35. 364

    12

    Returns: {352, 358 }

  36. 306

    339

    Returns: {0, 136 }

  37. 363

    156

    Returns: {207, 285 }

  38. 126

    39

    Returns: {87, 106 }

  39. 970

    58

    Returns: {912, 941 }

  40. 655

    1289

    Returns: {0, 10 }

  41. 227

    177

    Returns: {50, 138 }

  42. 984

    139

    Returns: {845, 914 }

  43. 977

    433

    Returns: {544, 760 }

  44. 649

    533

    Returns: {116, 382 }

  45. 780

    1290

    Returns: {0, 135 }

  46. 883

    412

    Returns: {471, 677 }

  47. 937

    1434

    Returns: {0, 220 }

  48. 80

    93

    Returns: {0, 33 }

  49. 348

    378

    Returns: {0, 159 }

  50. 603

    729

    Returns: {0, 238 }

  51. 402

    597

    Returns: {0, 103 }

  52. 161

    292

    Returns: {0, 15 }

  53. 887

    1153

    Returns: {0, 310 }

  54. 654

    321

    Returns: {333, 493 }

  55. 435

    355

    Returns: {80, 257 }

  56. 275

    340

    Returns: {0, 105 }

  57. 14

    19

    Returns: {0, 4 }

  58. 206

    350

    Returns: {0, 31 }

  59. 113

    49

    Returns: {64, 88 }

  60. 287

    82

    Returns: {205, 246 }

  61. 614

    1015

    Returns: {0, 106 }

  62. 965

    609

    Returns: {356, 660 }

  63. 969

    517

    Returns: {452, 710 }

  64. 882

    1091

    Returns: {0, 336 }

  65. 434

    107

    Returns: {327, 380 }

  66. 100

    193

    Returns: {0, 3 }

  67. 100

    100

    Returns: {0, 50 }

  68. 100

    0

    Returns: {100, 100 }

  69. 5

    2

    Returns: {3, 4 }

  70. 650

    350

    Returns: {300, 475 }

  71. 5

    10

    Returns: {0, 0 }

  72. 10

    5

    Returns: {5, 7 }

  73. 7

    3

    Returns: {4, 5 }


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: