题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=3288

Resource Allocation

Description

HDU-Sailormoon is made up of three girls~~~wj, xq, lff, usually they work together ---- solve a variety of problems. So they has to use some resources in the process.
In order to make it more convenient, they will put some resources in a box big enough, each resource has its ID and level of priority. When they want a kind of resources, they will give its ID and get it from the box. If there are several ones available in the box, they will get the highest priority ones. If there are still several ones available, they will get the one which puts in the box first.

Input

The input will consist of several cases, please deal with till the end of file. Each case contains a integer N(0<N<=10000), representing there are N steps following. For example, if input is "R x y"(x, y are integers,0<=x,y<=10000), representing they put a resource to the box, its ID is x, and its priority is y(the higher the priority is, the smaller the y is). If input is "name r" (name may be "wj" or "xq" or "lff", r is an integer,0<=r<=10000), representing one girl called "name" wants a resource, which ID is r.

Output

When the input is "R x y", the resource will mark a number k (begin from 1). When the input is "name r", please find out a resource in the box, if there is one available, print "name gets Num k: x y!", name referred to the input, k is the mark number of resource, x is the resource's ID and y is the level of priority, or print "No one fits!".

Sample Input

9
R 1 5
R 2 3
R 1 5
R 2 0
wj 1
xq 2
lff 3
lff 2
xq 2

Sample Output

wj gets Num 1: 1 5!
xq gets Num 4: 2 0!
No one fits!
lff gets Num 2: 2 3!
No one fits!

优先队列。。

 #include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::set;
using std::pair;
using std::vector;
using std::multiset;
using std::priority_queue;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
const int N = ;
typedef unsigned long long ull;
struct Node {
int fix, pos;
Node(int i = , int j = ) :fix(i), pos(j) {}
inline friend bool operator<(const Node &a, const Node &b) {
return a.fix == b.fix ? a.pos > b.pos : a.fix > b.fix;
}
};
priority_queue<Node> que[N];
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
char buf[];
int n, id, fix;
while (~scanf("%d", &n)) {
int pos = ;
rep(i, n) {
scanf("%s", buf);
if (buf[] == 'R') {
scanf("%d %d", &id, &fix);
que[id].push(Node(fix, pos++));
} else {
scanf("%d", &id);
if (que[id].empty()) { puts("No one fits!"); continue; }
Node t = que[id].top(); que[id].pop();
printf("%s gets Num %d: %d %d!\n", buf, t.pos, id, t.fix);
}
}
rep(i, N) while (!que[i].empty()) que[i].pop();
}
return ;
}

hdu 3288 Resource Allocation的更多相关文章

  1. Spark动态资源分配-Dynamic Resource Allocation

    微信搜索lxw1234bigdata | 邀请体验:数阅–数据管理.OLAP分析与可视化平台 | 赞助作者:赞助作者 Spark动态资源分配-Dynamic Resource Allocation S ...

  2. Hadoop Aggregate Resource Allocation解释

    1.在hadoop里面运行程序的时候,查看某个任务的具体信息如下: [hadoop@master monitor]$ yarn application -list 如上图,这里面的Aggregate ...

  3. HDU - 3247 Resource Archiver (AC自动机,状压dp)

    \(\quad\)Great! Your new software is almost finished! The only thing left to do is archiving all you ...

  4. Resource Allocation of Yarn

    关键词:yarn 资源分配 mapreduce spark 简要指南 适合不想看太多原理细节直接上手用的人. 基本原则: container分配的内存不等于机器实际用掉的内存.NM给container ...

  5. HDU 3247 Resource Archiver (AC自己主动机 + BFS + 状态压缩DP)

    题目链接:Resource Archiver 解析:n个正常的串.m个病毒串,问包括全部正常串(可重叠)且不包括不论什么病毒串的字符串的最小长度为多少. AC自己主动机 + bfs + 状态压缩DP ...

  6. HDU 3247 Resource Archiver (AC自动机+BFS+状压DP)

    题意:给定 n 个文本串,m个病毒串,文本串重叠部分可以合并,但合并后不能含有病毒串,问所有文本串合并后最短多长. 析:先把所有的文本串和病毒都插入到AC自动机上,不过标记不一样,可以给病毒标记-1, ...

  7. Service Function Chaining Resource Allocation: A Survey

    摘要: 服务功能链(SFC)是未来Internet的一项关键技术. 它旨在克服当前部署模型的僵化和静态限制. 该技术的应用依赖于可以将SFC最佳映射到衬底网络的算法. 这类算法称为"服务功能 ...

  8. HDU 3247 Resource Archiver(AC自动机 + 状压DP + bfs预处理)题解

    题意:目标串n( <= 10)个,病毒串m( < 1000)个,问包含所有目标串无病毒串的最小长度 思路:貌似是个简单的状压DP + AC自动机,但是发现dp[1 << n][ ...

  9. Solving Large-Scale Granular Resource Allocation Problems Efficiently with POP(2021-POP-SOSP-文献阅读笔记)

    读者 这篇文章来自2021的SOSP,单位是斯坦福大学和微软.选该文章的理由有二,一是资源分配的主题较为相关:二是文章结构.语言很清晰,读起来很舒服. 本文的中心思想可以概括为:分化瓦解,各个击破.即 ...

随机推荐

  1. OSGI.NET 插件无法启动之情景一

    关于osgi.net 的使用网上也有不少的资料,最近在使用osgi.net  开发插件的时候,遇到了这样的bug,造成插件甚至整个项目都无法启动,异常的具体消息如下: Could not find a ...

  2. 实现web页面按比例缩放

    对于web的掌握限于可以看懂别人的代码,并在框架中作相应修改或增加. 今天把另一个项目中的网页源代码粘过来做一个页面,结果问题百出. 首先,同样的代码,放在自己的项目里,页面排版错乱,看了下,引用的w ...

  3. 揭秘TPM安全芯片技术及加密应用

    揭秘TPM安全芯片技术及加密应用 首发:http://safe.it168.com/a2012/0912/1396/000001396884.shtml 从2003年开始,重要数据丢失已经成为严重的信 ...

  4. Windows API——CREATEEVENT——创建事件

    事件是一个允许一个线程在某种情况发生时,唤醒另外一个线程的同步对象.事件告诉线程何时去执行某一给定的任务,从而使多个线程流平滑 CreateEvent是创建windows事件的意思,作用主要用在判断线 ...

  5. css选择器分类

    css选择器大致可以分为10大类: 1.元素选择器 如:p{} 2.类选择器 如:.xx{} 3.ID选择器 如:#xx{} 4.关联选择器 如:p a{} 5.子元素选择器 如:p>a{} 6 ...

  6. 【MySQL】MySQL无基础学习和入门之二:MySQL的安装

    安装MySQL安装一般分为源码包编译安装.分发包.rpm包安装和yum安装,四种安装方式有一些区别,对应的适用场景也不一样. 源码包:源码包就是程序源代码包,其中包含程序代码文件,这些代码文件是文本型 ...

  7. ◆ 火狐浏览器去除JS方法:

    ◆ 火狐浏览器去除JS方法: 在火狐地址栏输入about:config   回车 在搜索地址栏中输入javascript.enabled 右键 当一行的中的,值由false变成trun,就OK了 . 

  8. WP8_(windows phone环境下)上传文件从C#到php接口

    在windows phone环境下,将手机上的图片上传到服务端(php环境): 注意事项:在上传的地方,头文件中name,例如name= img,则在php服务端处理时 ,需要约定好 存取一致 php ...

  9. linux 下安装 搭建 svn服务器

    1.下载svn http://subversion.apache.org/download 下载完成后解压,执行 ./configure --prefix=/usr/svn 提示 configure: ...

  10. EntityFramework追踪Sql语句

    方法一:SQL Profile 这个工具只有sql标准版(standard) 及以上版本才有,我装的是SqlServer2012 Express,所以采用方法2. 方法二:EntityFramewor ...