#P5813. [WC2001] 高性能计算机
[WC2001] 高性能计算机
Problem Description
You now have a time-critical engineering computation task to complete, as the chief engineer of a national high-performance parallel computer. To make full use of the advantages of parallel computing, the computation task should be split into several smaller subtasks.
This large computation task consists of two independent smaller computation tasks, and . To fully use the computing power of the parallel computer, these tasks need to be decomposed. It is found that both and can each be divided into many smaller subtasks. The workload of all type subtasks is the same, and the workload of all type subtasks is also the same (the workloads of type and type subtasks are not necessarily the same). There is no required execution order between tasks and , nor among the subtasks.
This supercomputer has computing nodes. Each node includes a serial processor, local main memory, and high-speed cache. However, due to long-term use and inconsistent upgrades, the computing abilities of the nodes are not symmetric. A node’s computing ability includes the following aspects:
-
For this task, each node has three working states: standby, type , and type . In type state it executes type tasks; in type state it executes type tasks; in standby state it does not compute. All processors are in standby before starting work. Switching from any other state into working state or (including switching between and ) requires a certain startup time. This time may differ across nodes. Use two positive integers and () to represent the startup time (in ns) for node to enter working state and working state , respectively.
-
When a node continuously processes tasks of the same type, the execution time (excluding state switching time) grows with the square of the task amount (the number of subtasks of that type), i.e.:
If node continuously processes type subtasks, the corresponding execution time is .
Similarly, if node continuously processes type subtasks, the corresponding execution time is .
Here, and are coefficients in ns, for .
Task assignment must be completed before any computation starts. “Task assignment” means setting a task queue for each computing node. The queue consists of a sequence of type and type subtasks. The two types of subtasks can be interleaved.
After computation starts, each node reads computation tasks from its own task queue in order and executes them. A consecutive block of same-type subtasks in the queue will be read and executed by that node in one batch, and such a consecutive block cannot be split into two parts for execution.
You need to write a program to schedule the computation tasks for these nodes so that the engineering computation task can be completed as early as possible. Assume the schedule will not change after being set, and all nodes start running at the same time. The goal is to make the completion time of the last finishing node as early as possible.
Input Format
The first line describes the computation tasks, containing two positive integers and , which are the numbers of type and type subtasks, respectively. The two integers are separated by one space.
The following part describes the computer:
The second line contains an integer , the number of computing nodes.
Then follow lines describing the nodes in order. Node is described on line , which contains four positive integers (separated by one space): .
Output Format
Only one line containing one positive integer: the time from when all nodes start computing until the task is completed.
5 5
3
15 10 6 4
70 100 7 2
30 70 1 6
93
Hint
For all testdata: , , , , , , 。
Translated by ChatGPT 5