Codevs1156 Job Scheduling Scheme (noip2006 raise group T3)

Source: Internet
Author: User
Description Description

Now we need to use M machines to process N parts, each of which has m processes, each of which is completed on different designated machines. Each process of each workpiece has a specified processing time.

Each process of each workpiece is called an operation. We use the Mark J-K to represent an operation, where J is a number from 1 to n and is the workpiece number; K is a number ranging from 1 to M. It is a serial number. For example, 2-4 indicates the operation of 2nd processes for 4th workpieces. In this question, we also give an order for each operation.

For example, when n = 3, m = 2, "1---" is a given order, that is to say, first arrange 1st processes for 1st workpieces, then arrange 1st processes for 2nd workpieces, and then arrange 2nd processes for 1st workpieces.

On the one hand, each operation must meet the following two constraints.

(1) For the same workpiece, each process must be completed before it can begin;

(2) Each machine can process at most one workpiece at a time.

On the other hand, you cannot change the working status of the previously scheduled operation when you schedule subsequent operations.

Because the same workpiece is arranged in the order of the process, only the workpiece number is given in the original order, and the same order can still be obtained. Therefore, in the input data, we abbreviated the order as "1 1 2 3 3 2 ".

Note that the "arrangement order" only requires that each operation be arranged in the given order. Not necessarily the actual operation sequence on each machine. During the specific implementation, it is possible that an operation is completed first than the previous operation.

For example, n = 3, m = 2. The known data is as follows:

The two implementation plans in the "1 1 2 3 3 2" order are correct. However, the total time required is 10 and 12 respectively.

 

When an operation is inserted to an empty file of a machine (the last part of the machine that has not been scheduled can also be regarded as a blank file), the operation can be inserted before, back or center. In order to make the problem simpler, we agree that we should try to insert it in front of the constraints (1) (2. In addition, we also agree that if there are multiple blank files that can be inserted, it will be inserted to the first blank file under the condition that the constraint condition (1) (2) is guaranteed. Therefore, under these conventions, solution 1 in the above example is correct, and solution 2 is incorrect.

Obviously, under these conventions, the implementation scheme that matches the given arrangement sequence is unique. Please calculate the total time required for the scheme to complete all tasks.



Train of Thought: It's a pity that I have been studying my Chinese skills... I thought it was DP at first. After reading it for a long time, I found it later... Simulation... After reading the data, it is easy to simulate. A find function can handle everything... But it is still repeated several times because the array range is smaller... (SAD ~)

However, we should celebrate that all questions of the raise group in have been completed !!! Suddenly I found that all the questions in 06 had the shadows of DP, but this wonderful Chinese Question was simulated...

Code:
# Include <iostream> # include <cstdio> using namespace STD; int Eng [21] [21] = {0}, Ti [21] [21] = {0 }, st [500] = {0}, last [21] = {0}, pre [21] = {0}; bool timm [21] [10000] = {false }; int find (int x, int XX, int y) {int I, j; bool FF = false, FI = false; I = last [X]; while (! Ff) {Fi = false; For (j = I; j <I + Ti [x] [XX]; ++ J) {If (timm [y] [J]) {I = J; while (timm [y] [I]) ++ I; FI = true; break ;}} if (! FI) FF = true;} return I;} int main () {int n, m, I, j, T, ANS = 0; CIN> m> N; for (I = 1; I <= N * m; ++ I) CIN> st [I]; for (I = 1; I <= N; ++ I) for (j = 1; j <= m; ++ J) CIN> Eng [I] [J]; for (I = 1; I <= N; ++ I) for (j = 1; j <= m; ++ J) CIN> Ti [I] [J]; for (I = 1; I <= N * m; ++ I) {++ pre [st [I]; t = find (ST [I], pre [st [I], eng [st [I] [pre [st [I]); For (j = T; j <t + Ti [st [I] [pre [st [I]; ++ J) timm [ENG [st [I] [pre [st [I] [J] = true; last [st [I] = T + Ti [st [I] [pre [st [I];} for (I = 1; I <= N; ++ I) ans = max (ANS, last [I]); cout <ans <Endl ;}

Codevs1156 Job Scheduling Scheme (noip2006 raise group T3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.