Work is so much more fun when we are part of a team! By combining our different skills, we can be more creative, efficient and productive. And more importantly, when working together we share... not only pizzas, but also knowledge. We can learn from each other, improve our own skills and gain experience.
Teamwork is one of the main ingredients of Hash Code, especially in this challenge!
So, are you up for the challenge?
You are given a list of contributors, who have already mastered various skills, and a list of projects with different skill requirements. Contributors can improve their skills by completing projects and can mentor each other to work is roles in which they couldn't succeed on their own. Your task is to assign contributors to project roles that fit their qualifications and maximize the score for completed projects.
There are $$$N$$$ contributors. Each contributor has a name and one or more skills at a specific level $$$(0, 1, 2, ...)$$$. Not possessing a skill is equivalent to possessing a skill at level 0.
For example, three contributors could have the following skills:
There are $$$ M $$$ projects. Each project is described by:
Each project has one or more roles that need to be filled by contributors. Each role requires one skill at a specific level, and can be filled by a single contributor. Each contributor can fill at most one role on a single project.
For example, a project called "WebServer" could have the following roles:
A contributor can be assigned to a project for a specific role (at most one role in a single project), if they either:
One contributor can mentor multiple people at once, including for the same skill. A contributor can mentor and be mentored by other contributors at the same time.
Not possessing a skill is equivalent to possessing a skill at level 0. So a contributor can work on a project and be assigned to a role with requirement C++ level 1 if they don’t know any C++, provided that somebody else on the team knows C++ at level 1 or higher.
For the project WebServer above we could make the following assignments:
Role 0 (requires Python level 3) is assigned to Anna (Python level 3).
Role 1 (requires HTML level 1) is assigned to Bob (C++ level 3).
Role 2 (requires CSS level 5) is assigned to Maria (HTML level 4, CSS level 6)
Each contributor can start working on day 0 and can be working on at most one project at the same time. Once the work on a project starts, its contributors will be working on it the number of days equal to its duration and then become available to work on other projects.
For example, if the project WebServer has duration of 7 days and starts on day 0, the contributors assigned to it will be working on it during: day 0, day 1, day 2, day 3, day 4, day 5 and day 6. On day 7 the project is already completed. Contributors assigned to it can work on another project on day 7.
Completing a project is a learning opportunity, especially for the contributors working on the edge of their existing abilities! When each project is completed:
Note that mentoring someone doesn’t increase the level of the skill for the mentor.
In the assignments above:
Each input data set is provided in a plain text file. The file contains only ASCII characters with lines ending with a single '\n' character (also called “UNIX-style” line endings). When multiple strings and numbers are given in one line, they are separated by a single space between each two elements.
The first line of the data set contains:
This is followed by $$$ C $$$ sections describing individual contributors. Each contributor is described by the following lines:
This is followed by $$$ P $$$ sections describing individual projects. Each project is described by the following lines:
The submission file should be a plaintext file containing only ASCII characters.
Your submission describes which projects each contributor is going to work on and in which role.
The first line should contain the integer $$$ E$$$ $$$(0 \leq E \leq P)$$$ – the number of executed projects.
This should be followed by E sections each describing one completed project. Each project should be described by two lines:
Each contributor can only work on one project at a time. If one contributor is assigned to multiple projects, the contributor will work on them in the same order as they appear in the submission file. Each project starts immediately on the first day on which all the assigned contributors are available.
If some project assignment is invalid because the assigned contributor does not have the required skill level for the project after finishing all previously assigned projects, the submission is considered invalid and will not be scored.
Each project that is completed successfully receives its assigned score, as defined in the input file, minus penalty points for any delay. If a project is completed after its “best before” time, it gets one point less for each day it is late (but no less than zero points). Note that even if a project scores zero points, the assigned contributors will work on it (and may improve their skills thanks to it).
The total score is the sum of scores for all correctly completed projects.
The example submission results in this timeline:
Day 0 to day 6: Bob and Anna are working on project WebServer (they both have the skills required).
Project WebServer's last day of work is day 6, so it completes strictly before its "best before" day 7 and receives the full score: 10 points.
Day 7 to 11: Anna is working on the project Logging (she has sufficient C++ skill after completing project WebServer).
Project Logging's last day of work is 11 (so it's completed strictly before day 12), while its "best before" day was 5. It is late by ($$$ 12 - 5 = $$$) 7 days and receives a score of: ($$$ 10 - 7 = $$$) 3 points.
Day 7 to 16: Maria and Bob are working on project WebChat
Project WebChat's last day of work is day 16, while the "best before" day is 20, so it receives the full score: 20 points.
In the end, projects Webserver (10 points), Logging (3 points) and WebChat (20 points) are completed, resulting in a total score of 33 points.
Note that there are multiple data sets representing separate instances of the problem. The final score for your team will be the sum of your best scores for the individual data sets.