p2751 Job Processing
如果单单只安排过程1的时间最短,很容易算出来。用优先队列取最小,加上增量后再放回就行。对过程2也进行这样的操作。将过程1第一个完成的在过程2最后一个完成。以样例来说,过程1:1,1,2,2,3,过程2:1,2,3,3,4。那么小的和大的组合用时最少。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF,mod=;
int inc[SZ]; struct nd{
int val,id;
nd(int a,int b):val(a),id(b){}
bool operator<(const nd &rbs)const
{
return val>rbs.val;
}
};
struct nnd{
int val,id;
nnd(int a,int b):val(a),id(b){}
bool operator<(const nnd &rbs)const
{
return val>rbs.val;
}
}; int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
int n,num1,num2;
cin>>n>>num1>>num2;
priority_queue<nd> pq1;
priority_queue<nnd> pq2;
for(int i=;i<=num1+num2;++i)
{
cin>>inc[i];
if(i<=num1)
{
pq1.push(nd(inc[i],i));
}
else pq2.push(nnd(inc[i],i));
}
vector<int> res1,res2;
for(int i=;i<n;++i)
{
nd tmp=pq1.top();
res1.push_back(tmp.val);
pq1.pop();
tmp.val+=inc[tmp.id];
pq1.push(tmp);
}
for(int i=;i<n;++i)
{
nnd tmp=pq2.top();
res2.push_back(tmp.val);
pq2.pop();
tmp.val+=inc[tmp.id];
pq2.push(tmp);
}
sort(res1.begin(),res1.end());
sort(res2.begin(),res2.end());
cout<<res1[res1.size()-]<<" ";
int maxv=;
for(int i=;i<res1.size();++i)
{
maxv=max(maxv,res1[i]+res2[res1.size()-i-]);
}
cout<<maxv<<endl;
}
return ;
}
p2751 Job Processing的更多相关文章
- 洛谷P2751 [USACO4.2]工序安排Job Processing
P2751 [USACO4.2]工序安排Job Processing 18通过 78提交 题目提供者该用户不存在 标签 难度普及+/提高 提交 讨论 题解 最新讨论 暂时没有讨论 题目描述 一家工 ...
- 洛谷 P2751 [USACO4.2]工序安排Job Processing 解题报告
P2751 [USACO4.2]工序安排Job Processing 题目描述 一家工厂的流水线正在生产一种产品,这需要两种操作:操作A和操作B.每个操作只有一些机器能够完成. 上图显示了按照下述方式 ...
- 洛谷P2751 工序安排Job Processing
题目 任务调度贪心. 需要明确一点,任务调度贪心题,并不是简单地应用排序的贪心,而是动态的运用堆,使每次选择是都能保持局部最优,并更新状态使得下次更新答案可以取到正确的最小值. 这是A过程的解. 然后 ...
- OLTP(on-line transaction processing)与OLAP(On-Line Analytical Processing)
OLTP与OLAP的介绍 数据处理大致可以分成两大类:联机事务处理OLTP(on-line transaction processing).联机分析处理OLAP(On-Line Analytical ...
- 新书到手 TRANSACTION PROCESSING:CONCEPTS AND TECHNIQUES
新书到手 TRANSACTION PROCESSING:CONCEPTS AND TECHNIQUES Jim Gray大神的著作 本文版权归作者所有,未经作者同意不得转载.
- Report processing of Microsoft Dynamic AX
Report processing of Microsoft Dynamic AX 版权声明:本文为博主原创文章,未经博主允许不得转载. The implementation of a general ...
- ANNOTATION PROCESSING 101 by Hannes Dorfmann — 10 Jan 2015
原文地址:http://hannesdorfmann.com/annotation-processing/annotationprocessing101 In this blog entry I wo ...
- ORA-01078: failure in processing system parameters & LRM-00109: could not open parameter file
安装了Oracle 12C后,启动数据库的过程中出现如下错误 SQL> startup ORA-01078: failure in processing system parameters LR ...
- Processing基础之绘画
图形 //在(x, y)绘制点 point(x, y); //(x1, y1)到(x2, y2)的一条线 line(x1, y1, x2, y2); rect(x, y, weight, height ...
随机推荐
- topcoder srm 687 div1
1.$A_{1}=2,A_{2}=3,A_{n}=A_{n-2}+A_{n-1}-1$.给出数字$n$,将其表示成若干个$A$中的不同元素的和. 思路:设$B_{n}=A_{n}-1$,那么有$B_{ ...
- eMMC分区详解【转】
本文转载自:https://blog.csdn.net/wxh0000mm/article/details/77864002 转自:http://blog.csdn.net/junzhang1122/ ...
- linux 子shell subshell和函数
关于子shell, subshell 参考:http://blog.csdn.net/sosodream/article/details/5683515 系统引导时的进程为 "原始进程&qu ...
- try finally 执行顺序问题
有return的情况下try catch finally的执行顺序 在遇到Exception 并且没有catch的情况下finally语句块没有执行 System.exit(0),终止了 Java 虚 ...
- hash进阶:使用字符串hash乱搞的姿势
前言 此文主要介绍hash的各种乱搞方法,hash入门请参照我之前这篇文章 不好意思hash真的可以为所欲为 在开头先放一下题表(其实就是我题解中的hash题目qwq) 查询子串hash值 必备的入门 ...
- asp.net core mvc 中在C# 代码中写 js 或html 文本
https://blog.csdn.net/orichisonic/article/details/62046621 使用<text>这个伪元素来强制Razor从编译模式返回到内容模式: ...
- 搭建git 服务器
Gogs 什么是 Gogs? Gogs 是一款极易搭建的自助 Git 服务. https://gogs.io/docs
- sublime text 中文显示异常
本文链接:sublime text 中文显示异常 http://www.cnblogs.com/daysme/p/7549857.html 前言 sublime text 3143 用了一年时候,最近 ...
- 【NOI 2016】优秀的拆分
Problem Description 如果一个字符串可以被拆分为 \(AABB\) 的形式,其中 \(A\) 和 \(B\) 是任意非空字符串,则我们称该字符串的这种拆分是优秀的. 例如,对于字符串 ...
- maven . mac
编辑文件 .bash_profile 1.vim .bash_profile 输入: M2_HOME=/Users/lizhimin/Documents/maven/apache-maven-3.3. ...