USACO 4.2 Job Processing
IOI'96
A factory is running a production line that requires two operations to be performed on each job: first operation "A" then operation "B". Only a certain number of machines are capable of performing each operation.
Figure 1 shows the organization of the production line that works as follows. A type "A" machine takes a job from the input container, performs operation "A" and puts the job into the intermediate container. A type "B" machine takes a job from the intermediate container, performs operation "B" and puts the job into the output container. All machines can work in parallel and independently of each other, and the size of each container is unlimited. The machines have different performance characteristics, a given machine requires a given processing time for its operation.
Give the earliest time operation "A" can be completed for all N jobs provided that the jobs are available at time 0. Compute the minimal amount of time that is necessary to perform both operations (successively, of course) on all N jobs.
PROGRAM NAME: job
INPUT FORMAT
Line 1: | Three space-separated integers:
|
Line 2..etc: | M1 integers that are the job processing times of each type "A" machine (1..20) followed by M2 integers, the job processing times of each type "B" machine (1..20). |
SAMPLE INPUT (file job.in)
5 2 3 1 1 3 1 4
OUTPUT FORMAT
A single line containing two integers: the minimum time to perform all "A" tasks and the minimum time to perform all "B" tasks (which require "A" tasks, of course).
SAMPLE OUTPUT (file job.out)
3 5
——————————————————————————————————————
假设A,B都获得了n个工件然后进行加工,我们通过循环判断哪个用时最少交给哪个,最后我们得到了A处理第1,2,3,4……工件所用的时间,B处理第1,2,3,4工件所用的时间
他们是一个递增的线段
然后发现A用时最短的应该交给B用时最长的
1 /* 2 ID:ivorysi 3 PROG:job 4 LANG:C++ 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <queue> 10 #include <set> 11 #include <vector> 12 #define inf 0x7fffffff 13 #define ivorysi 14 #define siji(i,x,y) for(int i=(x);i<=(y);++i) 15 #define gongzi(j,x,y) for(int j=(x);j>=(y);--j) 16 #define xiaosiji(i,x,y) for(int i=(x);i<(y);++i) 17 #define sigongzi(j,x,y) for(int j=(x);j>(y);--j) 18 using namespace std; 19 int n,m1,m2; 20 int a[35],b[35],usea[35],useb[35]; 21 int spa[1005],spb[1005],ans; 22 void init() { 23 scanf("%d%d%d",&n,&m1,&m2); 24 siji(i,1,m1) { 25 scanf("%d",&a[i]); 26 } 27 siji(i,1,m2) { 28 scanf("%d",&b[i]); 29 } 30 } 31 void solve() { 32 init(); 33 int mina,ida,minb,idb; 34 siji(i,1,n) { 35 mina=usea[1]+a[1];ida=1; 36 minb=useb[1]+b[1];idb=1; 37 siji(j,2,m1) { 38 if(usea[j]+a[j]<mina) { 39 mina=usea[j]+a[j]; 40 ida=j; 41 } 42 } 43 siji(j,2,m2) { 44 if(useb[j]+b[j]<minb) { 45 minb=useb[j]+b[j]; 46 idb=j; 47 } 48 } 49 usea[ida]=mina; 50 useb[idb]=minb; 51 spa[i]=mina; 52 spb[i]=minb; 53 } 54 siji(i,1,n) { 55 ans=max(ans,spa[i]+spb[n-i+1]); 56 } 57 printf("%d %d\n",mina,ans); 58 } 59 int main(int argc, char const *argv[]) 60 { 61 #ifdef ivorysi 62 freopen("job.in","r",stdin); 63 freopen("job.out","w",stdout); 64 #else 65 freopen("f1.in","r",stdin); 66 #endif 67 solve(); 68 return 0; 69 }
- 洛谷P2751 [USACO4.2]工序安排Job Processing
- USACO Section 4.2 Job Processing - 贪心
- usaco Job Processing
- Job Processing[USACO]
- usaco-4.2-job-passed
- USACO Job Processing 解题报告
- usaco training 4.2.3 Job Processing 题解
- USACO4.2.3 Job Processing (job)
- [USACO4.2.3 Job Processing]
- USCAO Job Processing 4.2(贪心,不知道叫啥方法)
- USACO Job Processing
- USACO4.2.3 Job Processing (job)
- USACO Training 4.2.3 Job Processing 工序安排 题解与分析
- BZOJ 1572: [Usaco2009 Open]工作安排Job
- bzoj1572 [Usaco2009 Open]工作安排Job
- [USACO4.2]草地排水Drainage Ditches
- [bzoj1572][Usaco2009 Open]工作安排Job_贪心_堆
- BZOJ1572 [Usaco2009 Open]工作安排Job
- 【USACO4.2】草地排水Drainage Ditches(最大流)
- USACO 4.2 草地排水 Drainage Ditches