UVAlive 5864 Register Allocation 题解
来源:互联网 发布:凯迪网络手机版 编辑:程序博客网 时间:2024/05/19 06:35
题目
Tri_integral Summer Training 4
题意:
有一些事件,已知发生的时间段(闭区间)。如果两个事件发生的时间没有交集,则可以安排在同一天,求至少要几天。
题解:
将所有事件插入set中,一个事件发生后,选择第一个在它结束后发生的事件,如果没有,开始新的一天。
//Time:26ms//Memory:0KB//Length:1047B#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <set>#define MAXN 20010#define INF 1000000007#define MP(x,y) make_pair(x,y)#define FI first#define SE secondusing namespace std;int s[MAXN],f[MAXN];bool vi[MAXN];set<pair<int,int> > se;pair<int,int> pa[MAXN];int main(){ //freopen("/home/moor/Code/input","r",stdin); int ncase,n,top,ans,pre; scanf("%d",&ncase); while(ncase--) { memset(vi,0,sizeof(vi)); top=0; scanf("%d",&n); se.clear(); for(int i=1;i<=n;++i) { scanf("%d%d",&s[i],&f[i]); se.insert(MP(s[i],i)); } ans=0; while(se.size()) { ++ans; set<pair<int,int> > ::iterator ite=se.begin(); int to; while(ite!=se.end()) { to=f[ite->SE]; se.erase(ite); ite=se.upper_bound(MP(to,INF)); } } printf("%d\n",ans); }}
- UVAlive 5864 Register Allocation 题解
- UVALive 5864 - Register Allocation
- UVALive 5864 Register Allocation 解题报告
- UVA 5864 - Register Allocation
- UVALive 6935 Bricks题解
- [WebKit] JavaScriptCore解析--高级篇(三) Register Allocation & Trampoline
- 【基础练习】【DFS】poj1129 Channel Allocation题解
- UVAlive 5863 Probability Computation 题解
- UVAlive 5867 Finding Feasible Paths 题解
- UVAlive 5866 Robot Arm Planning 题解
- 【poj 1129】Channel Allocation 题意&题解&代码(C++)
- 题解:洛谷P1937 [USACO10MAR]仓配置Barn Allocation
- Review on existing open-source Register Allocation algorithms with GCC\LLVM
- register
- register
- register
- Register
- register
- J2EE基于MVC的各层的设计原则及其编写注意事项
- ETL的过程原理和数据仓库建设
- 130720CF解题报告
- 判断顶点是否位于三角形内
- ZK grid or list数据多列排序
- UVAlive 5864 Register Allocation 题解
- OpenCV 编码样式指南
- 使用json-lib将xml转换为json
- vs2010 快捷键大全
- C++的数据类型
- 解决中文乱码的各种方案
- QT的隐式共享(Implicit Sharing)
- 进入WinPE蓝屏咋处理?
- 对J2EE应用系统分层设计的思考