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 ...
随机推荐
- python --- 06 小数据池 编码
一.小数据池, id() 进行缓存 1.小数据池针对的是: int, str, bool 2.在py文件中几乎所有的字符串都会缓存. 在cmd命令窗口中几乎都不会缓存 不同的解释器有不同 ...
- topcoder srm 713 div1
problem1 link 如果$a^{b}=c^{d}$,那么一定存在$t,x,y$使得$a=t^{x},c=t^{y}$.一旦$t,x,y$确定,那么可以直接计算出二元组$b,d$有多少.对于$t ...
- C Primer Plus 创建友好的输入界面 笔记
看代码 char inputFunCode; while(inputFunCode = getchar()){ '){ printf("you choose string conn\n&qu ...
- 倍数|计蒜客2019蓝桥杯省赛 B 组模拟赛(一)
思路:从l枚举到r肯定超时,这时我们要转变思路!题目让我们求一个区间内的d的倍数,只需要求出r/d - l/d就是区间内d倍数的个数. 代码: #include <iostream> us ...
- UVA 10318 Security Panel(DFS剪枝 + 状压 + 思维)题解
题意:给一个r*c的矩阵开关(初始全打开的),每次按下一个开关都会改变3*3范围内的有*的地方的状态,问你最少几步能让开关全闭上,按升序输出按哪些按钮 思路:每个按钮至多按一下,按按钮的顺序和结果无关 ...
- map数据结构
学习map的这种ES6新加的数据结构.在一些构建工具中是非常喜欢使用map这种数据结构来进行配置的,因为map是一种灵活,简单的适合一对一查找的数据结构.我们知道的数据结构,已经有了json和set. ...
- Jenkins-Publish HTML reports
创建job:testreport 在job中添加: 在Jenkins服务器上: 创建目录: .jenkins/jobs/{job名称}/workspace/htmlreports 注:此处job ...
- error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/share': Operation not permitted
参考: Python pip安装模块报错 Mac升级到EI Captain之后pip install 无法使用问题 error: could not create '/System/Library/F ...
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset(01字典树求最大异或值)
http://codeforces.com/contest/706/problem/D 题意:有多种操作,操作1为在字典中加入x这个数,操作2为从字典中删除x这个数,操作3为从字典中找出一个数使得与给 ...
- HDU 5791 Two(LCS求公共子序列个数)
http://acm.split.hdu.edu.cn/showproblem.php?pid=5791 题意: 给出两个序列,求这两个序列的公共子序列的总个数. 思路: 和LCS差不多,dp[i][ ...