Statistics

Problem Statement for "SumoTournament"

Problem Statement

There are several sumo wrestlers registered for the current season. You are given a int[] weight, where the i-th element is the weight of the i-th wrestler. One or more of these wrestlers are registered in this week's tournament. You are given an int averageWeight, which is the exact average weight of the wrestlers registered in the tournament. Return the maximal possible weight of a wrestler who might be in this tournament, or -1 if the average is not possible with the given input.

Definition

Class:
SumoTournament
Method:
maxWeight
Parameters:
int[], int
Returns:
int
Method signature:
int maxWeight(int[] weight, int averageWeight)
(be sure your method is public)

Constraints

  • averageWeight will be between 1 and 200, inclusive.
  • weight will contain between 1 and 50 elements, inclusive.
  • Each element of weight will be between 1 and 200, inclusive.

Examples

  1. {80,90,100}

    90

    Returns: 100

    There are three possible tournaments with an average weight of 90: {80,90,100}, {80,100}, {90}. Thus, it is possible that the wrestler with weight 100 is in the tournament.

  2. {81,90,150}

    90

    Returns: 90

  3. {1,2,4,8,16,32,64,128, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40,41,42}

    53

    Returns: 128

  4. {1,2,4,8,16,32,64,128, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40,41,42}

    93

    Returns: -1

  5. {10,20}

    15

    Returns: 20

  6. {40,30,20,10}

    27

    Returns: -1

    There is no way to achieve an average weight of 27.

  7. {181,187,174,180,199,174,188,188,192,184,175,175,171,197,171,181,195,172,197,176,191,194,172,173,192,192,191,196,178,175,187,176,181,188,179,192,187,189,195,194,193,191,172,173,173,184,191,171,193,198}

    174

    Returns: 192

  8. {184,192,197,197,189,193,191,189,198,186,175,190,182,188,186,180,172,174,198,196,185,190,179,180,190,176,191,173,178,179,193,194,174,176,190,186,196,181,198,194,179,196,183,187,198,178,182,179,181,173}

    175

    Returns: 184

  9. {189,188,194,170,197,196,193,176,181,175,184,192,170,179,187,173,197,182,186,170,181,176,175,187,185,174,181,192,190,180,191,174,186,180,197,181,177,197,177,187,173,173,175,199,189,178,181,188,172,186}

    174

    Returns: 191

  10. {139,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199}

    146

    Returns: 153

  11. {4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200}

    101

    Returns: 200

  12. {191,197,15,1,10,5,19,19,3,5,6,6,2,8,2,12,16,3,8,17,12,5,3,14,13,3,2,17,19,16,8,7,12,19,10,13,8,20,16,15,4,12,3,14,14,5,2,12,14,9}

    12

    Returns: 20

  13. {191,197,35,1,20,25,29,9,13,15,6,46,32,28,12,42,46,43,28,37,42,5,3,4,43,33,22,17,19,46,48,27,22,39,20,13,18,50,36,45,4,12,23,34,24,15,42,12,4,19}

    19

    Returns: 50

  14. {181,187,194,180,189,184,198,198,182,184,26,26,2,28,2,12,36,23,28,37,32,5,23,34,13,23,22,37,39,16,8,7,12,19,30,33,28,20,36,15,24,12,3,14,34,25,22,32,14,29}

    13

    Returns: 39

  15. {181,187,194,180,189,184,198,198,182,184,185,185,181,187,181,191,195,182,187,196,22,25,3,4,23,23,22,27,9,6,18,7,12,19,10,23,18,20,26,25,24,22,3,4,4,15,22,2,24,29}

    19

    Returns: 29

  16. {200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200}

    200

    Returns: 200

  17. {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176}

    17

    Returns: 25

  18. {200,193,191,156,70,48,152,3,32,93,87,179,29,47,105,75,22,48,149,85,6,146,33,39,75,169,189,194,13,65,161,137,93,57,35,91,64,193,187,181,108,191,43,98,161,64,145,148,3,142}

    159

    Returns: 200

  19. {32,96,29,149,124,117,178,101,20,94,46,16,94,5,103,103,171,107,111,4,39,13,122,129,138,144,154,89,152,160,37,70,110,30,10,3,94,104,47,187,45,93,47,58,74,185,50,99,178,142}

    165

    Returns: 187

  20. {81,122,44,11,145,149,122,148,31,127,165,166,41,32,40,153,194,45,13,199,23,27,155,188,119,149,169,10,6,81,121,120,171,6,25,52,11,65,142,22,101,48,185,55,80,190,199,3,121,136}

    179

    Returns: 199

  21. {27,106,111,199,69,23,63,116,159,194,168,6,194,186,75,35,196,95,111,28,65,58,28,77,27,115,135,18,143,114,104,27,177,106,65,154,35,98,64,82,34,46,14,26,178,174,113,10,91,46}

    62

    Returns: 199

  22. {46,44,94,147,120,31,186,101,19,141,36,85,173,163,184,40,188,173,169,167,140,98,194,148,24,144,80,7,80,146,30,48,97,103,33,157,187,181,117,142,127,5,15,151,56,57,12,142,140,51}

    58

    Returns: 194

  23. {158,90,112,86,19,14,141,150,182,194,32,160,83,64,99,98,146,38,180,12,35,112,192,179,46,140,193,79,97,26,182,159,27,123,27,19,193,148,128,26,166,131,46,133,105,129,30,147,137,160}

    132

    Returns: 194

  24. {127,172,182,133,88,113,179,101,23,50,104,21,22,167,88,59,71,158,91,177,50,191,153,114,195,32,20,178,68,92,161,166,166,169,185,173,166,137,50,5,30,65,3,136,105,137,88,184,3,188}

    179

    Returns: 195

  25. {41,200,89,52,158,108,8,138,167,179,41,10,105,82,25,111,135,173,70,92,87,2,94,94,8,126,107,52,43,95,146,187,111,146,163,109,161,46,27,123,196,1,17,163,102,41,30,59,19,197}

    200

    Returns: 200

  26. {126,165,125,9,86,60,39,43,100,35,4,175,68,163,130,23,28,68,139,104,158,81,118,123,3,171,29,86,163,169,126,151,107,79,198,33,102,60,27,50,143,152,72,76,77,46,23,43,72,182}

    58

    Returns: 198

  27. {6,196,78,82,1,67,186,44,58,72,178,185,19,105,131,37,111,132,25,74,136,14,51,189,105,183,191,161,168,194,7,27,54,36,92,110,193,187,19,168,122,169,45,124,35,120,19,73,107,176}

    9

    Returns: 19

  28. {115,89,5,42,44,167,79,101,86,73,160,112,161,130,197,45,159,135,19,171,132,111,61,57,2,54,161,73,192,147,102,129,68,155,25,86,46,53,120,161,119,112,22,95,139,105,176,19,99}

    82

    Returns: 197

  29. {39,141,31,95,12,63,42,152,14,194,178,91,179,124,71,7,196,185,58,20,93,3,179,103,138,7,146,64}

    107

    Returns: 196

  30. {82,97,18,35,122,16,18,50,126,134,58,106,14,49,162,163,22,94,38,92,110,59,144,119,82,5,163,133,84,197,61,91}

    192

    Returns: -1

  31. {76,101,9,71,116,58,106,172,48,200,104,95,72,130,70,184,81,79,97,21,51,13,45,150,63,125,79,183,152,97,52,14,84,75,114,150,42,16,30,179,94,125,22,158,26,160,32}

    123

    Returns: 200

  32. {3,178,130,110,124,172,179,104,40,59,198,76,177,119,105,162,134,63,171,115,43,195,89}

    52

    Returns: 115

  33. {114,62,3,86,5,81,161,62,43,41,72,188,87,20,198,109,184,185,155,29,127,194,64,101,142,31,120,187,79,190,19,185,154,39,33,98,67,144,76}

    138

    Returns: 198

  34. {116,81,166,158,153,193,45,78,129,34,45,134,145,19,144,41,121,160,24,11,124}

    131

    Returns: 193

  35. {152,57,172,54,12,56,50,55,139,185,170,17,106,113,175,135,133,182,116,39,138,78,134,144,78,11,132,27,135,18,163,175,114,51,37,169,182,179,27,180,177,81,131,126,97,86,147,179}

    5

    Returns: -1

  36. {158,29,93,129,118,156,7,67,188,163,76,183,68,187,146,31,164,20,139,160,118,25,110,107,11,171,117,46,75,25,118,135,179,87,198,57,158,52,11,194,71,192,176}

    188

    Returns: 198

  37. {166,55,3,48,46,58,30,180,150,90,105,83,98,164,154,8,162,25,123,185}

    51

    Returns: 185

  38. {115,15,114,30,14,118,167,32,163,165,163,14,15,15,110,113,17,37,30,16,33,170,22,108,19,111,119,115,120,117,113,30,32,29,166,164,17,19,19,111,19,36,17,164,35,36,109,168,114,32}

    22

    Returns: 37

  39. {94,148,155,87,90,147,151,179,188,177,188,150,147,150,180,183,188,192,180,180,149,145,181,156,176,152,178,144,156,91,187,148,154,193,156,90,190,154,178,177,146,191,144,177,88,184,155,146,146,144}

    102

    Returns: 155

  40. {78,90,35,88,80,54,86,34,32,84,80,35,54,84,85,80,56,33,61,53,79,73,78,81,59,85,33,82,88,81,34,80,86,82,89,54,76,86,89,81,32,34,61,85,87,32,80,85,73,82}

    34

    Returns: 35

  41. {109,193,45,191,110,43,173,113,192,186,179,191,110,176,43,124,124,192,45,46,190,48,46,173,126,111,190,178,47,48,45,49,44,125,118,106,175,111,173,175,108,172,44,43,175,122,191,172,45,190}

    53

    Returns: 126

  42. {12,20,5,12,25,110,111,149,113,118,17,4,1,1,20,17,151,16,27,17,4,114,149,13,4,5,21,18,20,1,1,2,150,18,149,149,14,22,148,144,11,15,110,151,4,146,3,16,13,148}

    6

    Returns: 27

  43. {84,108,110,112,88,35,88,78,86,89,85,83,85,45,107,91,105,79,84,29,44,85,77,33,83,106,82,80,78,111,39,84,35,82,109,89,84,40,40,110,90}

    46

    Returns: 112

  44. {67,126,148,63,57,47,55,43,58,69,54,65,133,133,65,127,43,43,126,53,56,66,48,41,71,128,68,129,68,44,68,53,70,144,130,58,68,41,149,145,54}

    47

    Returns: 71

  45. {155,139,46,153,138,45,42,40,147,43,137,150,136,139,47,128,46,51,50,53,48,46,129,53,128,134,52,49,53,139,137,46,52,52,147,139,152,48,139,134,45,151}

    45

    Returns: 53

  46. {68,117,171,168,119,61,61,153,69,65,175,121,153,86,63,168,153,61,176,83,174,66,176,84,117,123,148,117,125,82,149,81,171,149,120,87,151,150}

    73

    Returns: 125

  47. {34,39,73,30,79,31,71,137,135,136,34,136,72,70,31,73,136,35,75,31,40,70,141,32,73,32,69,76,72,71,143,35,34,69,137,139,70,31,36,29,37,37,67,141,78,77,135,32,136}

    44

    Returns: 143

  48. {100}

    100

    Returns: 100

  49. {80,90,100}

    85

    Returns: 90

  50. {10, 10, 10, 10, 10, 10, 10, 10, 10, 50, 20, 20, 30, 50, 60, 40, 60, 40, 60, 20, 30, 50, 60, 40 }

    25

    Returns: 60

  51. {42, 68, 135, 101, 170, 125, 79, 159, 163, 65, 106, 146, 82, 28, 162, 92, 196, 143, 28, 37, 192, 5, 103, 154, 93, 183, 22, 117, 119, 96, 48, 127, 172, 139, 70, 113, 68, 100, 36, 95, 104, 12, 123, 134, 74, 65, 142, 112, 54, 69 }

    26

    Returns: 65


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: