# 4.2.3 Job Processing 工序安排

4.2.3 Job Processing 工序安排

``````5 2 3
1 1 3 1 4
``````

``````3 5
``````

``````#include <stdio.h>
#include <algorithm>
#include <functional>
#include <fstream>

#define min(a, b) (a>b?b:a)
#define max(a, b) (a>b?a:b)

using namespace std;

int d[3][55];
int leng[3][55];
int cost[3][1005];

int main()
{
int n;
while (scanf("%d %d %d", &n, &leng[1][0], &leng[2][0]) == 3)
{
int i, j, k;
int et[3] = {0};
for (i=1; i<=leng[1][0]; i++)
scanf("%d", &leng[1][i]);
for (i=1; i<=leng[2][0]; i++)
scanf("%d", &leng[2][i]);
for (i=1; i<3; i++)
{
for (j=1; j<=n; j++)
{
int min = 99999999;
int s;
for (k=1; k<=leng[i][0]; k++)
{
int t = d[i][k] + leng[i][k];
if (min > t)
{
min = t;
s = k;
}
}
d[i][s] = min;
cost[i][j] = min;
}
}
sort(&cost[1][1], &cost[1][1] + n, less<int>());
sort(&cost[2][1], &cost[2][1] + n, greater<int>());
for (i=1; i<=n; i++)
{
et[1] = max(et[1], cost[1][i]);
et[2] = max(et[2], (cost[1][i] + cost[2][i]));
}
printf("%d %d\n", et[1], et[2]);
}
return 0;
}``````

``````#include <stdio.h>
#include <algorithm>
#include <functional>
#include <fstream>

#define min(a, b) (a>b?b:a)
#define max(a, b) (a>b?a:b)

using namespace std;

int d[3][55];
int leng[3][55];
int cost[3][1005];

int main()
{
int n;
while (scanf("%d %d %d", &n, &leng[1][0], &leng[2][0]) == 3)
{
int i, j, k;
int et[3] = {0};
for (i=1; i<=leng[1][0]; i++)
scanf("%d", &leng[1][i]);
for (i=1; i<=leng[2][0]; i++)
scanf("%d", &leng[2][i]);
for (i=1; i<3; i++)
{
for (j=1; j<=n; j++)
{
int min = 99999999;
int s;
for (k=1; k<=leng[i][0]; k++)
{
int t = d[i][k] + leng[i][k];
if (min > t)
{
min = t;
s = k;
}
}
d[i][s] = min;
cost[i][j] = min;
}
}
sort(&cost[1][1], &cost[1][1] + n, less<int>());
sort(&cost[2][1], &cost[2][1] + n, greater<int>());
for (i=1; i<=n; i++)
{
et[1] = max(et[1], cost[1][i]);
et[2] = max(et[2], (cost[1][i] + cost[2][i]));
}
printf("%d %d\n", et[1], et[2]);
}
return 0;
}``````