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:

  • 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)
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用时最长的

 /*
ID:ivorysi
PROG:job
LANG:C++
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#define inf 0x7fffffff
#define ivorysi
#define siji(i,x,y) for(int i=(x);i<=(y);++i)
#define gongzi(j,x,y) for(int j=(x);j>=(y);--j)
#define xiaosiji(i,x,y) for(int i=(x);i<(y);++i)
#define sigongzi(j,x,y) for(int j=(x);j>(y);--j)
using namespace std;
int n,m1,m2;
int a[],b[],usea[],useb[];
int spa[],spb[],ans;
void init() {
scanf("%d%d%d",&n,&m1,&m2);
siji(i,,m1) {
scanf("%d",&a[i]);
}
siji(i,,m2) {
scanf("%d",&b[i]);
}
}
void solve() {
init();
int mina,ida,minb,idb;
siji(i,,n) {
mina=usea[]+a[];ida=;
minb=useb[]+b[];idb=;
siji(j,,m1) {
if(usea[j]+a[j]<mina) {
mina=usea[j]+a[j];
ida=j;
}
}
siji(j,,m2) {
if(useb[j]+b[j]<minb) {
minb=useb[j]+b[j];
idb=j;
}
}
usea[ida]=mina;
useb[idb]=minb;
spa[i]=mina;
spb[i]=minb;
}
siji(i,,n) {
ans=max(ans,spa[i]+spb[n-i+]);
}
printf("%d %d\n",mina,ans);
}
int main(int argc, char const *argv[])
{
#ifdef ivorysi
freopen("job.in","r",stdin);
freopen("job.out","w",stdout);
#else
freopen("f1.in","r",stdin);
#endif
solve();
return ;
}

USACO 4.2 Job Processing的更多相关文章

  1. USACO 完结的一些感想

    其实日期没有那么近啦……只是我偶尔还点进去造成的,导致我没有每一章刷完的纪念日了 但是全刷完是今天啦 讲真,题很锻炼思维能力,USACO保持着一贯猎奇的题目描述,以及尽量不用高级算法就完成的题解……例 ...

  2. usaco training 4.2.3 Job Processing 题解

    Job Processing题解 IOI'96 A factory is running a production line that requires two operations to be pe ...

  3. 洛谷P2751 [USACO4.2]工序安排Job Processing

    P2751 [USACO4.2]工序安排Job Processing 18通过 78提交 题目提供者该用户不存在 标签 难度普及+/提高 提交  讨论  题解 最新讨论 暂时没有讨论 题目描述 一家工 ...

  4. USACO . Your Ride Is Here

    Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often co ...

  5. OLTP(on-line transaction processing)与OLAP(On-Line Analytical Processing)

    OLTP与OLAP的介绍 数据处理大致可以分成两大类:联机事务处理OLTP(on-line transaction processing).联机分析处理OLAP(On-Line Analytical ...

  6. 【USACO 3.1】Stamps (完全背包)

    题意:给你n种价值不同的邮票,最大的不超过10000元,一次最多贴k张,求1到多少都能被表示出来?n≤50,k≤200. 题解:dp[i]表示i元最少可以用几张邮票表示,那么对于价值a的邮票,可以推出 ...

  7. USACO翻译:USACO 2013 NOV Silver三题

    USACO 2013 NOV SILVER 一.题目概览 中文题目名称 未有的奶牛 拥挤的奶牛 弹簧牛 英文题目名称 nocow crowded pogocow 可执行文件名 nocow crowde ...

  8. USACO翻译:USACO 2013 DEC Silver三题

    USACO 2013 DEC SILVER 一.题目概览 中文题目名称 挤奶调度 农场航线 贝西洗牌 英文题目名称 msched vacation shuffle 可执行文件名 msched vaca ...

  9. USACO翻译:USACO 2014 DEC Silver三题

    USACO 2014 DEC SILVER 一.题目概览 中文题目名称 回程 马拉松 奶牛慢跑 英文题目名称 piggyback marathon cowjog 可执行文件名 piggyback ma ...

随机推荐

  1. tomcat 性能检测

    一.jconsole 1.tomcat在windows上,start方式启动 在catalina.bat 文件中的:doRun和:doStart下添加以下代码 (没有换行) set JAVA_OPTS ...

  2. Linux清屏命令

    1:clear 2:Ctrl+L 3:printf "\033c" 4:ALT+F8 By KillerLegend Ref:http://www.coolcoder.in/201 ...

  3. IIS错误整理收集【持续更新】

    一.HTTP 错误 403.14 - Forbidden HTTP 错误 403.14 - Forbidden,Web 服务器被配置为不列出此目录的内容. 解决方案:修改程序池.NET Framewo ...

  4. Perl file checking --- How to get information about a file

    There are some short expressions in Perl that allow you to test files, which is handy if you want to ...

  5. css3-自定义字体

    参考链接http://www.w3cplus.com/content/css3-font-face 出处W3CPLUS css3-自定义字体   @font-face @font-face是CSS3中 ...

  6. 【精选】Nginx负载均衡学习笔记(一)实现HTTP负载均衡和TCP负载均衡(官方和OpenResty两种负载配置)

    说明:很简单一个在HTTP模块中,而另外一个和HTTP 是并列的Stream模块(Nginx 1.9.0 支持) 一.两个模块的最简单配置如下 1.HTTP负载均衡: http { include m ...

  7. CSS只改变背景透明度,不改变子元素透明度

    一般情况下,我们可以使用css的opcity属性改变某个元素的透明度,但是其元素下的子元素的透明度也会被改变,即使对子元素重新定义也没有用,例如: <div style="opacit ...

  8. 20155306 2016-2017-2 《Java程序设计》第6周学习总结

    20155306 2016-2017-2 <Java程序设计>第6周学习总结 教材学习内容总结 第十章 输入/输出 10.1 InputStream与OutputStream 如果要将数据 ...

  9. 微服务深入浅出(5)-- 声明式调用Feign

    Feign的使用 Feign采用了声明式的API接口的风格,将Java Http客户端绑定到它的内部,从而调用过程变的简单. 配置文件: spring: application: name: eure ...

  10. POJ 1350 Cabric Number Problem (模拟)

    题目链接 Description If we input a number formed by 4 digits and these digits are not all of one same va ...