Statistics

Problem Statement for "ProblemSetsEasy"

Problem Statement

Cat Snuke came up with some problems. He wants to construct as many problem sets as possible using those problems. Each problem set must contain exactly three problems: one for the Easy slot, one for the Medium slot, and one for the Hard slot. Each problem can only be assigned to a single slot in a single problem set. He came up with E + EM + M + MH + H problems in total. The distribution of the problems is as follows:
  • E problems can only be used in the Easy slot.
  • EM problems can be used either in the Easy slot or the Medium slot.
  • M problems can only be used in the Medium slot.
  • MH problems can be used either in the Medium slot or the Hard slot.
  • H problems can only be used in the Hard slot.
Return the maximal number of problem sets he can construct.

Definition

Class:
ProblemSetsEasy
Method:
maxSets
Parameters:
int, int, int, int, int
Returns:
int
Method signature:
int maxSets(int E, int EM, int M, int MH, int H)
(be sure your method is public)

Constraints

  • E, EM, M, MH, H must be between 0 and 100000, inclusive.

Examples

  1. 2

    2

    1

    2

    2

    Returns: 3

    One of EM problems should be used for the Easy slot, and the other should be used for the Medium slot. One of MH problems should be used for the Medium slot, and the other should be used for the Hard slot.

  2. 100

    100

    100

    0

    0

    Returns: 0

    Unfortunately, no problem can be used for the Hard slot.

  3. 657

    657

    657

    657

    657

    Returns: 1095

  4. 1

    2

    3

    4

    5

    Returns: 3

  5. 100000

    100000

    100000

    100000

    100000

    Returns: 166666

  6. 0

    0

    0

    0

    0

    Returns: 0

  7. 49326

    53800

    252

    95743

    32128

    Returns: 77083

  8. 31450

    8540

    54092

    49778

    65081

    Returns: 39990

  9. 68762

    21648

    95151

    27210

    630

    Returns: 27840

  10. 22025

    1998

    4442

    47054

    57196

    Returns: 24023

  11. 57965

    25930

    62252

    63644

    36165

    Returns: 81985

  12. 5239

    16167

    9959

    16301

    91083

    Returns: 21406

  13. 95943

    89465

    31427

    65224

    69738

    Returns: 117265

  14. 71920

    71787

    41486

    35552

    90178

    Returns: 103641

  15. 78074

    53341

    26144

    81393

    57089

    Returns: 98680

  16. 18292

    5562

    12607

    25242

    96949

    Returns: 23854

  17. 44155

    83412

    98154

    19163

    79295

    Returns: 98458

  18. 70406

    10595

    49864

    31584

    11831

    Returns: 43415

  19. 4263

    33574

    84213

    66913

    16566

    Returns: 37837

  20. 6036

    92614

    40948

    93219

    84079

    Returns: 98650

  21. 11849

    65804

    49153

    23028

    1715

    Returns: 24743

  22. 89780

    2972

    35139

    19554

    48757

    Returns: 53211

  23. 91864

    95115

    82803

    25105

    26244

    Returns: 51349

  24. 39418

    19957

    57701

    70001

    22510

    Returns: 59375

  25. 28353

    15018

    46920

    6853

    95980

    Returns: 43371

  26. 95008

    81775

    35073

    617

    2522

    Returns: 3139

  27. 47750

    74549

    4712

    24467

    61365

    Returns: 70947

  28. 82183

    66690

    58023

    64562

    81794

    Returns: 117750

  29. 63520

    54125

    76690

    12276

    20492

    Returns: 32768

  30. 46733

    90270

    42998

    34619

    73988

    Returns: 96202

  31. 39031

    67874

    79828

    11964

    67400

    Returns: 79364

  32. 36441

    58999

    20836

    89942

    74486

    Returns: 93568

  33. 89552

    15235

    71924

    41669

    30149

    Returns: 71818

  34. 82981

    58624

    97165

    90264

    15115

    Returns: 105379

  35. 53198

    34969

    95965

    62483

    71831

    Returns: 88167

  36. 66000

    77063

    57064

    90114

    15346

    Returns: 101862

  37. 83732

    13005

    56151

    79543

    89650

    Returns: 96737

  38. 39216

    41415

    4656

    88601

    60831

    Returns: 78239

  39. 78885

    96389

    1921

    18679

    45052

    Returns: 63731

  40. 52326

    51259

    21425

    68059

    14278

    Returns: 69115

  41. 49248

    54932

    462

    10627

    5738

    Returns: 16365

  42. 46606

    4894

    58846

    21698

    84645

    Returns: 51500

  43. 58052

    16571

    31915

    58716

    8042

    Returns: 57622

  44. 39546

    99297

    25857

    19783

    5204

    Returns: 24987

  45. 39227

    47644

    14869

    20823

    93370

    Returns: 61281

  46. 34693

    89498

    65043

    35658

    34211

    Returns: 69869

  47. 46369

    50372

    67839

    69468

    82688

    Returns: 96741

  48. 91703

    51466

    82054

    89399

    76400

    Returns: 130340

  49. 65592

    90698

    29351

    36196

    62887

    Returns: 94908

  50. 17341

    16131

    87095

    32425

    10790

    Returns: 33472

  51. 86280

    2118

    70037

    39819

    41755

    Returns: 76864

  52. 50632

    18463

    84736

    6131

    5191

    Returns: 11322

  53. 42317

    70101

    64076

    15581

    34608

    Returns: 50189

  54. 68512

    32520

    95447

    43844

    77813

    Returns: 101032

  55. 51301

    98147

    87040

    8607

    13844

    Returns: 22451

  56. 56991

    88229

    77728

    29620

    4290

    Returns: 33910

  57. 84698

    51239

    42193

    12837

    22294

    Returns: 35131

  58. 51044

    36485

    50563

    76749

    82311

    Returns: 87529

  59. 89719

    12246

    6804

    73857

    17799

    Returns: 55353

  60. 86239

    55179

    50899

    14124

    28545

    Returns: 42669

  61. 3910

    81269

    14501

    56847

    90899

    Returns: 78263

  62. 29876

    8517

    92236

    42738

    10071

    Returns: 38393

  63. 66705

    16641

    87677

    15842

    95554

    Returns: 83346

  64. 11134

    16461

    2164

    22565

    12872

    Returns: 21732

  65. 10220

    48485

    17058

    24450

    23580

    Returns: 41264

  66. 52819

    74370

    76530

    56557

    56154

    Returns: 105476

  67. 5

    7

    3

    9

    5

    Returns: 9

  68. 80

    100000

    100000

    100000

    100000

    Returns: 100080

  69. 1

    1

    1

    1

    1

    Returns: 1

  70. 0

    1

    0

    1

    1

    Returns: 1

  71. 4

    99999

    18

    99999

    12

    Returns: 66677

  72. 10

    0

    0

    10

    10

    Returns: 10

  73. 2

    5

    1

    0

    1

    Returns: 1

  74. 10

    0

    5

    15

    10

    Returns: 10

  75. 5

    7

    3

    8

    5

    Returns: 9

  76. 1

    2

    2

    100

    2

    Returns: 3

  77. 4

    1

    3

    3

    4

    Returns: 5

  78. 1000

    0

    20

    0

    10

    Returns: 10

  79. 1

    0

    0

    2

    0

    Returns: 1

  80. 100

    0

    100

    100

    100

    Returns: 100

  81. 1

    100

    1

    100

    1

    Returns: 67

  82. 1

    1

    2

    3

    4

    Returns: 2

  83. 100

    50

    0

    70

    99

    Returns: 106

  84. 1

    1

    1

    100

    0

    Returns: 2

  85. 0

    100

    0

    10000

    0

    Returns: 100

  86. 1

    8

    1

    1

    900

    Returns: 5

  87. 0

    200

    200

    200

    200

    Returns: 200

  88. 6

    0

    5

    5

    6

    Returns: 6

  89. 5

    5

    1

    5

    10

    Returns: 8

  90. 100

    0

    1

    100

    1

    Returns: 51

  91. 3

    1

    2

    0

    3

    Returns: 3


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: