#K35157. Project Management Simulation
Project Management Simulation
Project Management Simulation
In this problem, you are given a set of employees with their respective effectiveness scores and a series of project-related queries. There are three types of queries:
- Add Project: A new project is added with an initial difficulty value (d).
- Apply Effectiveness: An employee (e) attempts to reduce the difficulty of all projects that have a difficulty not less than a given threshold (d). For every project with (\text{project difficulty} \ge d), its difficulty decreases by the effectiveness of employee (e), i.e., (\text{project difficulty} = \text{project difficulty} - \text{effectiveness}[e-1]).
- Query Sum: You must output the sum of difficulties of all ongoing projects at that moment.
Your task is to simulate this procedure and print the results of all type-3 queries. The input will be read from standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains two integers (n) and (q), where (n) is the number of employees and (q) is the number of queries.
- The second line contains (n) space-separated integers representing the effectiveness scores of the employees.
- The next (q) lines each represent a query in one of the following formats:
- Type 1 (Add Project):
1 d
where (d) is the initial difficulty of the project. - Type 2 (Apply Effectiveness):
2 e d
where (e) is the 1-indexed employee number and (d) is the difficulty threshold. - Type 3 (Query Sum):
3
which requires you to output the current sum of project difficulties.
- Type 1 (Add Project):
outputFormat
For every type-3 query, output a single line containing the sum of the difficulties of all ongoing projects at that moment. The output is written to standard output (stdout).## sample
4 7
10 20 30 40
1 100
1 200
2 1 50
2 3 30
3
1 150
3
220
370
</p>