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. 华为手机不能连接android studio进行调试的解决办法

    出现情景:在开启了usb debugging(usb调试模式)后,AS(android studio)还是找不到真机. 解决办法:下载驱动精灵,检测是否安装了huawei的usb驱动,如果没有,安装成 ...

  2. 内存操作函数memmove,memcpy,memset

    通过字符串的学习,我们知道字符串操作函数的操作对象是字符串,并且它的结束标志是结束符\0,当然这个说的是不 受限制的字符串函数.然而当我们想要将一段内存的数据复制到另一块内存时,我们不能使用字符串操作 ...

  3. webpack的基础入门

    webpack的基础入门 这里对于 webpack 的基础入门进行一些总结,可以参考 github 上的 webpack-demo ,链接是 https://github.com/RealAndMe/ ...

  4. 你应该了解的强大CSS表达式 ----- expression

    IE5及其以后版本支持在CSS中使用expression,用来把CSS属性和Javas cript表达式关联起来,这里的CSS属性可以是元素固有的属性,也可以是自定义属性.就是说CSS属性后面可以是一 ...

  5. 20155209 2016-2017-2 《Java程序设计》第五周学习总结

    20155209 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 try语句用大括号{}指定了一段代码,该段代码可能会抛弃一个或多个例外. catch语句的参 ...

  6. postman pre-request-script 操作方法记录

    上代码----自己参考下就明白了 例子1:自动登陆获取token let chatHost,chatName,chatPassword;//设置环境变量 if (pm.environment.get( ...

  7. 使用TS+Sequelize实现更简洁的CRUD

    如果是经常使用Node来做服务端开发的童鞋,肯定不可避免的会操作数据库,做一些增删改查(CRUD,Create Read Update Delete)的操作,如果是一些简单的操作,类似定时脚本什么的, ...

  8. 【SLAM】安装 g2o_viewer

    2017年2月8日,那是一个阴天.为了完成高翔博士的<一起做RGB-D SLAM>教程,我在 Ubuntu 14.04 安装 g2o.遇到困难,怎奈我眼瞎,找错了方向,浪费时间,没有成功安 ...

  9. connect by和strart with子句

    --使用connect by和strart with子句 SELECT [level],column,expression, ... FROM table [WHERE where_clause] [ ...

  10. 跳出python的各种坑(1)

    2017-11-1915:38:17 一定要跳出python的各种坑,一开始遇到的好多思维上的认知错误,因为刚开始学习,对python是个什么都不清楚,所以记录一下自己遇到的各种坑.不用担心自己遇到的 ...