[USACO4.2.3]Job Processing
来源:互联网 发布:如何投诉淘宝平台 编辑:程序博客网 时间:2024/05/09 01:50
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.
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:- N, the number of jobs (1<=N<=1000).
- M1, the number of type "A" machines (1<=M1<=30)
- M2, the number of type "B" machines (1<=M2<=30)
SAMPLE INPUT (file job.in)
5 2 31 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
第一问:
考虑到每一个工件都是独立的然后我想到了NOIP普及组一道,好像是water??
不管
贪心!
就是每次加最少的地方去加
然后就解决了。
第二问:
不会。
还是贪心。
注意:(每一个工件都是独立的)
考虑对于A处理n个工件,每一个工件都有一定的处理完A的时间
最短的处理完B的时间
类似这样:(可能机器比较少)
1:———
2:—————
3:——————
_1:—
_2:———
_3:————
显然,最大和最小的匹配比较好。
题解真妙,好好理解!
/*ID:cqz15311LANG:C++PROG:job*/#include<bits/stdc++.h>const int inf = 1 << 20;using namespace std;int a[1005],b[1005];int timea[1005],timeb[1005],time1[1005],time2[1005];int n,na,nb,Min,ans,k;int main(){freopen("job.in","r",stdin);freopen("job.out","w",stdout);scanf("%d",&n);scanf("%d%d",&na,&nb);for (int i=1;i<=na;i++) scanf("%d",&a[i]);for (int i=1;i<=nb;i++) scanf("%d",&b[i]);memset(timea,0,sizeof(timea));memset(timeb,0,sizeof(timeb));for (int i=1;i<=n;i++) {Min = inf;for (int j=1;j<=na;j++){if (timea[j] + a[j] < Min) {Min = timea[j] + a[j];k = j;}}timea[k] = time1[i] = Min;}printf("%d ",Min);for (int i=1;i<=n;i++){Min = inf;for (int j=1;j<=nb;j++){if (timeb[j] + b[j] < Min){Min = timeb[j] + b[j];k = j;}}timeb[k] = time2[i] = Min;}ans = 0;for (int i=1;i<=n;i++)ans = max(ans,time1[i] + time2[n-i+1]);printf("%d\n",ans);fclose(stdin);fclose(stdout);}/*Executing... Test 1: TEST OK [0.000 secs, 4196 KB] Test 2: TEST OK [0.000 secs, 4196 KB] Test 3: TEST OK [0.000 secs, 4196 KB] Test 4: TEST OK [0.000 secs, 4196 KB] Test 5: TEST OK [0.000 secs, 4196 KB] Test 6: TEST OK [0.000 secs, 4196 KB] Test 7: TEST OK [0.000 secs, 4196 KB] Test 8: TEST OK [0.000 secs, 4196 KB] Test 9: TEST OK [0.000 secs, 4196 KB] Test 10: TEST OK [0.000 secs, 4196 KB] Test 11: TEST OK [0.000 secs, 4196 KB] Test 12: TEST OK [0.000 secs, 4196 KB]All tests OK.*/
阅读全文
0 0
- usaco4.2.3 Job Processing
- [USACO4.2.3]Job Processing
- USACO4.2.3 Job Processing (job)
- USACO4.2.3 Job Processing (job)
- USACO4.2.3/job
- Job Processing
- USACO Job Processing
- USACO 4.2 job processing
- usaco Job Processing(mark)
- usaco 4.2 Job Processing 贪心
- usaco 4.2 Job Processing(贪心)
- USACO Section 4.2 Job Processing
- usaco 4.2.3 Job Processing
- USACO Job Processing 解题报告
- USACO Section 4.2 Job Processing - 贪心
- usaco training 4.2.3 Job Processing 题解
- USACO-Section 4.2 Job Processing (贪心)
- ERROR common.AbstractJob: Unexpected SIMILARITY_EUCLIDEAN_DISTANCE while processing Job-Specific Opt
- Truck History POJ
- 关于汽车遥控器芯片EV1527的研究
- 拼多多2018校招内推编程题汇总
- Python 字典内容总结(完整)
- 懒省事的小名
- [USACO4.2.3]Job Processing
- Java面向字节流的应用
- EA画类图
- dp专题3--树形dp入门
- Codeforces Round #420 (Div. 2) 821D Okabe and City 思维建图+spfa
- 模拟实现C++STL中的string类
- 【ZZULIOJ 2171 】 举世伐唐 【线段树 区间修改+区间最大值】
- python实现两个任意字符串乘积
- hdu6069 Counting Divisors 质因数分解 区间筛