Statistics

Problem Statement for "Employee"

Problem Statement

PROBLEM STATEMENT

A group of supervisors at Acme Assembling, Inc., like to sleep in. However,
they are still responsible for keeping up a certain level of production at the
factory. Since it is against union rules for an employee to work without a
supervisor present, this presents a conflict of interest. So, the supervisors
have done some simple psychological analyses of their employees, and know that,
without a supervisor present, each individual has two factors which
parameterize his behavior. Each person has a certain time period which he will
wait for a supervisor to come (patience factor), and a people factor, which
determines how many other people must leave before he does (follow-the-leader
syndrome). Thus, in order to continue their analyses and thus be able to
maximize their sleeping-in habits, they've asked you to write a program to run
simulations of employee behavior, given each employee's parameters. Note that a
person will leave based on whichever condition is fulfilled first (patience or
people).

DEFINITION

Class name: Employee
Method name: patience
Parameters: String[], int
Returns: int[]

The method signature is as follows (make sure it is declared public):
int[] patience (String[] employees, int supervisor);

Each String in employees will be of the format "<String>,<int>,<int>,<int>",
which corresponds to "<NAME>,<START-TIME>,<PATIENCE FACTOR>,<PEOPLE FACTOR>".
(i.e., "John Smith,5,3,1"). There will be exactly one comma and no space
between the integers and between the name and the first integer. Quotes and
angle brackets are included for clarity only and will not be part of the String.
<START-TIME> is the hour at which the employee is scheduled to start work.
<PATIENCE FACTOR> is the number of hours the employee will wait for a
supervisor to arrive before he leaves.
<PEOPLE FACTOR> is the number of people for whom the employee will wait to
leave before he himself leaves. These people must all leave on or after the
time the employee arrives.

supervisor is the hour at which the supervisor comes in to the factory,
allowing the employees to work. 

The method should return an int[] of length 24, with each element containing
the number of people that left at that hour. i.e., index 0 of the return value
corresponsds to 0 o'clock, index 1 corresponds to 1 o'clock, 12 corresponds to
12 o'clock, 13 corresponds to 13 o'clock, etc.

NOTES
- Everyone arriving at a particular time sees everyone who leaves at that
time. Thus, if persons A and C arrive at 7 o'clock and person B leaves at 7
o'clock, persons A and C see person B leaving. Similarly, if person A then
leaves at 7 o'clock after seeing person B leave, person C has seen 2 people
leave.
- This problem is concerned with a single day only, starting at 0 o'clock and
ending 24 hours later.
 - Once a supervisor has arrived, he will stay until the end of the day. 
 - No one leaves on the hour on which the supervisor arrives.
 - Employees may have identical names. This affects nothing.


TopCoder will enforce the following restrictions:
* employees will have between 1 and 50 elements, inclusive
* Each String in employees will be between 1 and 50 characters in length,
inclusive
* The name of each employee will contain only letters (A-Z,a-z), numbers (0-9),
spaces, and periods
* For each employee, <START-TIME> will be between 0 and 23, inclusive
* For each employee, <PATIENCE FACTOR> and <PEOPLE FACTOR> will be between 0
and 51, inclusive
* supervisor will be between 0 and 23, inclusive

Examples:
{"Jane Doe,7,2,4",
"John Smith,8,3,2",
"Harry Hoser,8,1,1",
"Bob Lazy,8,0,0"}, 10
Prior to 7 o'clock, no one has come, thus no one has left. Jane Doe comes in to
work at 7, and no supervisors are there.
However, she will wait for up to 2 hours or 4 people to leave, whichever comes
first.
At 8 o'clock, the other three people arrive. Bob Lazy, having 0 patience and 0
people-factor, leaves immediately.
Seeing this, Harry Hoser, who has a people-factor of 1, has now seen 1 person
leave, and he leaves himself (still at 8 o'clock).
Seeing this, John Smith has now seen 2 people leave, and leaves.
At 9 o'clock, Jane Doe has been waiting for 2 hours, and leaves.
When the supervisor arrives at 10 o'clock, no one is left. So, 3 people left at
8 o'clock, and 1 left at 9 o'clock.
The return value is: {0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0}.

{"Oscar G. Rouch,3,4,3",
"W. T. Pooh,5,2,1",
"Dok,10,1,1",
"Zoidal,7,1,4",
"Chuck G. Nim,8,3,2"}, 9
Oscar comes in at 3.
W. T. Pooh comes in at 5. (Oscar has been waiting for 2 hours)
Zoidal comes in at 7. (Oscar has been waiting for 4 hours and leaves, so now
W.T. Pooh has seen 1 person leave and leaves).
Chuck G. Nim comes in at 8. (Zoidal now leaves, having waited for 1 hour).
Supervisor comes in at 9, and Chuck is still there.
Dok comes in at 10, and everything is kosher, because there is already a
supervisor there.
So, 2 people left at 7, 1 person left at 8, and no one else left.
The return value is: {0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0}

{"dok,8,0,0","Red man,7,1,5","Blue man,6,9,2","Green
man,5,9,3","Chuck,4,9,4","gt494,3,9,5","Alexander,2,10,6"}, 9 returns:
{0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

{"Hard worker,0,23,1","Lazy person,5,0,51"}, 5 returns:
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

{"Hard worker,0,23,1","Lazy person,5,0,51"}, 6 returns:
{0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Definition

Class:
Employee
Method:
patience
Parameters:
String[], int
Returns:
int[]
Method signature:
int[] patience(String[] param0, int param1)
(be sure your method is public)

Constraints

    Examples


      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: