题目链接

https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/C

代码如下:

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <bitset>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
const int MAXN = 1e6+;
struct Node
{
string s;
int time;
int d;
} a[MAXN];
bool cmp(Node a, Node b)
{
if(a.d == b.d)
return a.time > b.time;
return a.d > b.d;
}
struct cmp2
{
bool operator()(const Node a, const Node b)const
{
if(a.d == b.d)
return a.time > b.time;
return a.d > b.d;
}
};
struct cmp1
{
bool operator()(const Node a, const Node b)const
{
if(a.d == b.d)
return a.time < b.time;
return a.d < b.d;
}
};
set<Node,cmp1>se1;
set<Node,cmp2>se2;
map<string,Node>mp;
string s;
int main()
{
int n, m;
while(~scanf("%d",&n))
{
se1.clear();
se2.clear();
mp.clear();
double tp = 1.0*n*0.2;
int nn = (int)tp;
int tn = n;
for(int i=; i<=tn; i++)
{
a[i].time = i;
cin>>a[i].s>>a[i].d;
mp[a[i].s] = a[i];
}
sort(a+, a++tn, cmp);
for(int i=; i<=nn; i++)
se1.insert(a[i]);
for(int i=nn+; i<=n; i++)
se2.insert(a[i]);
scanf("%d",&m);
Node tmp;
for(int i=tn+; i<=tn+m; i++)
{
char op;
cin>>op;
if(op == '-')
{
cin>>s;
tmp = mp[s];
if(se1.erase(tmp)) nn--;
se2.erase(tmp);
if(nn>(int)(1.0*(n-)*0.2))
{
nn--;
tmp=*se1.begin();
se1.erase(tmp);
se2.insert(tmp);
cout<<tmp.s;
printf(" is not working now.\n");
}
n--;
if(nn<(int)(1.0*(n)*0.2))
{
nn++;
tmp=*se2.begin();
se1.insert(tmp);
se2.erase(tmp);
cout<<tmp.s;
printf(" is working hard now.\n");
}
}
else///++
{
cin>>a[i].s>>a[i].d;
a[i].time=i;
mp[a[i].s]=a[i];
//cout<<nn<<" "<<n<<endl;
if(nn<(int)(1.0*(n+)*0.2))///+0.2
{
if(a[i].d>(*se2.begin()).d||a[i].d==(*se2.begin()).d&&a[i].time>(*se2.begin()).time)
{
se1.insert(a[i]);
cout<<a[i].s;
printf(" is working hard now.\n");
}
else
{
tmp=*se2.begin();
se2.erase(tmp);
se1.insert(tmp);
se2.insert(a[i]);
cout<<a[i].s;
printf(" is not working now.\n");
cout<<tmp.s;
printf(" is working hard now.\n");
}
nn++;
//cout<<"nn"<<nn<<endl;
}
else///=0.2
{
if(nn!=)
{
tmp=*se1.begin();
if(a[i].d>tmp.d||a[i].d==tmp.d&&a[i].time>tmp.time)
{
se1.erase(tmp);
se1.insert(a[i]);
se2.insert(tmp);
cout<<a[i].s;
printf(" is working hard now.\n");
cout<<tmp.s;
printf(" is not working now.\n");
}
else
{
se2.insert(a[i]);
// se2.erase(tmp);
//se1.insert(tmp);
cout<<a[i].s;
printf(" is not working now.\n");
//cout<<tmp.s;
//printf(" is working hard now.\n");
///
}
}
else
{
tmp=*se2.begin();
if((int)(1.0*(n+)*0.2)>)
{
if(a[i].d>tmp.d||a[i].d==tmp.d&&a[i].time>tmp.time)
{
se1.insert(a[i]);
cout<<a[i].s;
printf(" is working hard now.\n");
}
else
{
se2.erase(tmp);
se2.insert(a[i]);
se1.insert(tmp);
cout<<a[i].s;
printf(" is not working now.\n");
cout<<tmp.s;
printf(" is working hard now.\n");
}
}
else
{
se2.insert(a[i]);
cout<<a[i].s;
printf(" is not working now.\n");
}
}
}
n++;
}///++
}
}
return ;
}

2016弱校联盟十一专场10.3---We don't wanna work!(STL--set的使用)的更多相关文章

  1. 2016弱校联盟十一专场10.3 We don't wanna work!

    能把 not working now 写成 not working hard now 还查一晚上也是没谁了 我的做法是维护两个set 分别是前20% 和后80% #include<iostrea ...

  2. 2016弱校联盟十一专场10.3 We don't wanna work!

    能把 not working now 写成 not working hard now 还查一晚上也是没谁了 我的做法是维护两个set 分别是前20% 和后80% #include<iostrea ...

  3. 2016弱校联盟十一专场10.5---As Easy As Possible(倍增)

    题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8506#problem/A problem description As we know, t ...

  4. 2016弱校联盟十一专场10.3---Similarity of Subtrees(深搜+hash、映射)

    题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52310 problem description Define the depth of a ...

  5. (2016弱校联盟十一专场10.3) D Parentheses

    题目链接 把左括号看成A右括号看成B,推一下就行了.好久之前写的,推到最后发现是一个有规律的序列. #include <bits/stdc++.h> using namespace std ...

  6. (2016弱校联盟十一专场10.3) B.Help the Princess!

    题目链接 宽搜一下就行. #include <iostream> #include<cstdio> #include<cstring> #include<qu ...

  7. (2016弱校联盟十一专场10.3) A.Best Matched Pair

    题目链接 #include<cstdio> #include<cstring> #include<algorithm> #include<stack> ...

  8. 2016弱校联盟十一专场10.2---Around the World(深搜+组合数、逆元)

    题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem  description In ICPCCamp, there ar ...

  9. (2016弱校联盟十一专场10.2) A.Nearest Neighbor Search

    题目链接 水题,算一下就行. #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x[],y[], ...

随机推荐

  1. 爱上MVC3~布局页的继承与扩展

    回到 目录 在MVC3中引入了Razor引擎,这对于代码的表现力上是个突破,同时母板页也变成了_Layout,所以,我们就习惯上称它为布局页面,在razor里,布局页面是可以继承的,即,一个上下公用的 ...

  2. EF架构~在Linq to Entity中使用日期函數

    回到目录 眾所周知,在linq to entity的查询语句中,不允许出现ef不能识别的关键字,如Trim,Substring,TotalDays等.net里的关键字,在EF查询里都是不被支持的,它的 ...

  3. [Spring框架]Spring JDBCTmplate基础入门总结.

    前言:前面有讲过 Spring IOC以及AOP的基本使用方法, 这里就再来讲下Spring JDBCTemplate的使用方法. 一, 概述这里先说一下Spring 整合的一些模板: 从上图中可以看 ...

  4. js 事件

    事件:一般用于浏览器与用户操作进行交互 js事件的三种模型:内联模型.脚本模型.DOM2模型 内联模型:事件处理函数是HTML标签的属性 <input type="button&quo ...

  5. angularjs学习曲线

    angularjs学习曲线 刚开始学Augular觉得开发应用需要有相当的编程基础. 不得不说这确实是一款了不起的开发框架,它要求开发人员设计低耦合和可维护的应用. 使用AngularJS 的复杂度就 ...

  6. linux下配置mysql默认编码utf8

    linux下配置mysql默认编码utf8 下面是需要在对应地方加入的配置 [client] default-character-set=utf8 [mysqld] character-set-ser ...

  7. 解决TryUpdateModel对象为空的问题

    MVC中的TryUpdateModel确实给开发带来不少便利,但是如果绑定在View上的文本控件没有填写值的时候,再执行TryUpdateModel对应的实体属性就会为空. 如果数据库中对应的字段不允 ...

  8. 【WP 8.1开发】如何把自定义字体塞进应用里

    或许,系统自带的字体不足以体现应用程序的魅力,对于表现极强的汉字来说,更是如此.这时候,我们就会想,要是能把网上下载的艺术字体塞到应用包中,那岂不美哉?那么,这可以实现吗?答案是Yes的. 接下来,阿 ...

  9. transform你不知道的那些事

    transform是诸多css3新特性中最打动我的,因为它让方方正正的box module变得真实了. transform通过一组函数实现了对盒子大小.位置.角度的2D或者3D变换.不过很长时间内,我 ...

  10. OpenCascade Shape Representation in OpenSceneGraph

    OpenCascade Shape Representation in OpenSceneGraph eryar@163.com 摘要Abstract:本文通过程序实例,将OpenCascade中的拓 ...