Problem Statement
Given the budget for new hires (in thousands) and a list of the possible employees, including their percentage score on the technical exam and their expected salaries (in thousands), determine the combination of employees that the company would hire. Return their average technical exam score, rounding up to the nearest integer if the decimal portion is .5 or higher, and rounding down otherwise. If there is no such set of three possible employees that can be hired, return -1.
Each element of applicants will be formatted as: "<employeeName>,<examScore>,<expectedSalary>", where <employeeName> is a sequence of between 1 and 20, inclusive, lowercase letters ('a'-'z'), <examScore> is an integer between 1 and 100, inclusive, and <expectedSalary> is an integer between 20 and 250, inclusive.
Definition
- Class:
- Hiring
- Method:
- recruit
- Parameters:
- int, String[]
- Returns:
- int
- Method signature:
- int recruit(int budget, String[] applicants)
- (be sure your method is public)
Constraints
- budget will be an integer between 1 and 1000, inclusive.
- applicants will contain between 3 and 50 elements, inclusive.
- each item in applicants will be of the form "
, , ". Note that these values are only comma separated, and will never have leading or trailing whitespace. will be between 1 and 20 characters, inclusive, and will only contain the characters 'a'-'z'. - No two employees will have the same
. will be an integer between 1 and 100, inclusive, with no leading zeroes. will be an integer between 20 and 250, inclusive with be no leading zeroes.
Examples
270
{"ndbronson,99,99", "malpt,97,90", "ambrose,97,70", "dmwright,94,100", "jonmac,98,94"}
Returns: 98
The recruiter would choose ndbronson, ambrose, and jonmac.
299
{"reid,100,100", "dgarthur,100,100", "zorbathut,100,100"}
Returns: -1
The recruiter could not hire three employees with this budget.
240
{"derkuci,85,70", "doeth,87,69", "snapdragon,82,75", "obfuscator,89,70", "evd,89,100", "milhouse,77,77", "stevevai,79,91", "po,83,76", "joe,90,73"}
Returns: 89
The recruiter would choose doeth, obfuscator, and joe.
200
{"a,70,70", "b,60,80", "c,100,100", "d,99,99", "e,98,98", "f,55,62", "g,66,66", "h,55,55", "i,100,100", "j,79,74", "k,98,98", "l,44,44", "m,33,33", "n,22,22", "o,69,69", "p,42,42", "q,11,80", "r,100,25", "s,50,50", "t,78,72", "u,82,69", "v,36,64", "w,99,24", "x,34,36", "y,92,92", "aa,70,70", "bb,60,80", "cc,100,100", "dd,99,99", "ee,98,98", "ff,55,62", "gg,66,66", "hh,55,55", "ii,100,100", "jj,79,74", "kk,98,98", "ll,44,44", "mm,33,33", "nn,22,22", "oo,69,69", "pp,42,42", "qq,11,80", "rr,50,25", "ss,50,50", "tt,78,72", "uu,82,69", "vv,36,64", "ww,99,24", "xx,34,36", "yy,50,50"}
Returns: 100
150
{"a,50,50", "b,51,50", "c,51,50"}
Returns: 51
150
{"a,51,50", "b,51,50", "c,51,51"}
Returns: -1
300
{"a,50,250", "b,50,100", "c,50,200", "d,50,50"}
Returns: -1
150
{"a,70,70", "b,60,80", "c,100,100", "d,99,99", "e,98,98", "f,55,62", "g,66,66", "h,55,55", "i,100,100", "j,79,74", "k,98,98", "l,44,44", "m,33,33", "n,22,22", "o,69,69", "p,42,42", "q,11,80", "r,75,25", "s,50,50", "t,78,72", "u,82,69", "v,36,64", "w,73,24", "x,34,36", "y,92,92", "aa,70,70", "bb,60,80", "cc,100,100", "dd,99,99", "ee,98,98", "ff,55,62", "gg,66,66", "hh,55,55", "ii,100,100", "jj,79,74", "kk,98,98", "ll,44,44", "mm,33,33", "nn,22,22", "oo,69,69", "pp,42,42", "qq,11,80", "rr,50,25", "ss,50,50", "tt,78,72", "uu,82,69", "vv,36,64", "ww,67,24", "xx,34,36", "yy,50,50"}
Returns: 83
100
{"a,33,33", "b,33,34", "c,34,33"}
Returns: 33
100
{"a,33,33", "b,33,34", "c,33,34"}
Returns: -1
1000
{"a,25,250", "b,35,250", "c,45,250", "d,55,250", "e,65,250", "f,65,250", "g,65,250", "h,65,250", "i,75,250", "j,85,250", "k,95,250"}
Returns: 85
80
{"twentyletternamesyay,1,25", "twentyletternameshoy,1,25", "hirethisdude,100,25", "iknoweverything,100,30", "iknownothing,1,100"}
Returns: 67
749
{"iwanttoomuchmoney,100,250", "iamevengreedier,100,250", "gimmecash,100,250"}
Returns: -1
100
{"a,100,25", "b,100,25", "c,100,25", "d,100,25", "e,100,25", "f,100,25", "g,100,25", "h,100,25", "i,100,25", "j,100,25"}
Returns: 100
333
{"pleasehireme,20,100", "willingtorelocate,50,111", "javaguru,100,222", "cplusplusguru,100,111", "superdebugger,50,111"}
Returns: 67
250
{"georgiagrad,100,100", "mitgrad,99,150", "stanfordgrad,98,149", "cornellgrad,97,125", "floridagrad,10,20", "tennesseegrad,9,20", "southcarolinagrad,8,20", "auburngrad,7,20", "alabamagrad,6,20", "kentuckygrad,5,20", "arkansasgrad,4,20", "gatechgrad,1,250"}
Returns: 69
300
{"a,33,33", "b,34,34", "c,34,34"}
Returns: 34
60
{"a,20,20", "b,20,20", "c,20,20"}
Returns: 20
150
{"a,100,149", "b,10,20", "c,10,20", "d,10,20"}
Returns: 10
300
{"a,90,220", "b,40,100", "c,40,100", "d,1,20", "e,1,20", "f,40,99"}
Returns: 40
240
{"a,85,70", "b,87,69", "c,82,75", "d,89,70", "e,89,100", "f,77,77", "g,79,91", "h,83,76", "j,90,73"}
Returns: 89
300
{"a,100,100", "b,100,100", "c,100,100"}
Returns: 100
240
{"derkuci,85,70", "doeth,87,69", "snapdragon,82,75", "obfuscator,89,70", "evd,89,100", "milhouse,77,77", "stevevai,79,91", "po,83,76", "joe,90,73"}
Returns: 89
1000
{"a,1,20", "b,1,20", "c,100,20", "d,1,20", "e,1,20", "f,1,20", "g,1,20", "h,1,20", "i,1,20"}
Returns: 34
100
{"a,99,33", "b,50,75", "c,50,75"}
Returns: -1
1000
{"a,1,20", "b,2,20", "c,1,20"}
Returns: 1
300
{"a,90,100", "b,90,150", "c,90,150"}
Returns: -1
200
{"a,90,140", "b,80,120", "c,80,120", "d,70,20", "e,70,20"}
Returns: 77
301
{"a,100,100", "b,2,200", "c,2,200"}
Returns: -1
50
{"a,50,250", "b,34,250", "c,54,250"}
Returns: -1
266
{"a,100,100", "x,34,56", "c,100,100", "d,100,66"}
Returns: 100
203
{"a,99,98", "b,77,100", "c,88,100", "d,55,20", "e,88,20"}
Returns: 81
100
{"a,1,30", "b,1,30", "c,1,30"}
Returns: 1
100
{"a,10,30", "b,10,30", "c,10,30", "d,10,30", "dddffdszfsf,10,30", "bdd,10,30", "e,10,30", "f,10,30", "g,10,30", "h,10,40", "i,10,30", "j,20,30", "k,10,40", "l,10,50", "m,10,40", "n,10,40", "o,10,30", "p,10,58", "q,10,40", "r,10,40", "s,10,30", "t,10,30", "u,10,40", "v,10,40", "w,10,40", "x,10,40", "y,10,50", "z,10,40", "aa,10,40", "bb,10,40", "cc,10,40", "dd,10,50", "ee,10,40", "ff,10,40", "gg,10,40", "hh,10,40", "ii,10,40", "jj,10,40", "kk,10,40", "ll,10,40", "mm,10,40", "nn,10,40", "oo,10,40", "pp,10,40", "qq,10,40", "dfdfd,10,40", "sdfsdfsdf,10,40", "dfgdgdfgdf,10,40", "gdfgdfd,10,40", "sfsdfwewerw,10,40"}
Returns: 13
100
{"a,33,33", "b,33,34", "c,34,33"}
Returns: 33
150
{"a,50,50", "b,50,50", "c,51,50"}
Returns: 50
30
{"a,100,100", "b,100,100", "c,100,100"}
Returns: -1
200
{"a,52,50", "b,52,50", "c,52,50", "d,54,50"}
Returns: 53
200
{"a,15,20", "b,15,20", "c,14,20"}
Returns: 15
100
{"a,1,20", "b,1,20", "c,2,20"}
Returns: 1
240
{"a,85,70", "b,87,69", "c,82,75", "d,89,70", "e,89,100", "f,77,77", "g,79,91", "h,83,76", "i,90,73"}
Returns: 89
200
{"a,90,140", "c,80,120", "b,80,100", "d,70,20", "e,70,20"}
Returns: 77
299
{"a,100,100", "b,100,100", "c,100,100"}
Returns: -1
199
{"a,100,100", "b,100,100", "c,100,100"}
Returns: -1
270
{"a,100,100", "b,90,90", "c,90,90", "d,80,80"}
Returns: 90
60
{"a,60,20", "b,60,20", "c,60,20"}
Returns: 60
100
{"a,50,50", "b,50,20", "c,50,50"}
Returns: -1
100
{"bob,1,20", "doug,1,20", "sue,2,20"}
Returns: 1
65
{"a,10,20", "b,9,21", "c,8,200", "d,7,22"}
Returns: 9
150
{"a,50,50", "b,51,50", "c,51,50"}
Returns: 51
180
{"a,80,80", "b,70,70", "c,60,60", "d,50,50", "e,40,45", "f,20,30"}
Returns: 60
300
{"a,90,220", "b,40,100", "c,40,100", "d,1,20", "e,1,20", "f,40,99"}
Returns: 40
60
{"a,2,20", "b,2,20", "c,2,30", "d,2,30", "e,1,20"}
Returns: 2
1
{"a,20,20", "b,20,20", "c,20,20"}
Returns: -1
240
{"a,85,70", "b,87,69", "c,82,75", "d,89,70", "e,89,100", "f,77,77", "g,79,91", "h,83,76", "i,90,73"}
Returns: 89
300
{"a,99,100", "b,99,100", "c,100,100"}
Returns: 99
1
{"a,99,99", "b,99,99", "c,99,99"}
Returns: UNKNOWN-OUTPUT10291821323
150
{"a,50,50", "b,50,50", "c,50,50"}
Returns: UNKNOWN-OUTPUT10291821323