题目链接

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. Atitit sql执行计划

    Atitit sql执行计划 1.1. 首先要搞明白什么叫执行计划? 执行计划是数据库根据SQL语句和相关表的统计信息作出的一个查询方案,这个方案是由查询优化器自动分析产生的 Oracle中的执行计划 ...

  2. paip.禁用IKAnalyzer 的默认词库.仅仅使用自定义词库.

    paip.禁用IKAnalyzer 的默认词库.仅仅使用自定义词库. 作者Attilax  艾龙,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http:// ...

  3. Linux设置SFTP服务用户目录权限

    我们有时会遇到这样的需求,限制一个Linux用户,让他只能在指定的目录下进行添加.修改.删除操作,并且只能使用sftp登录服务器,不能用ssh操作.这些可以通过配置sftp服务实现. 提供sftp服务 ...

  4. vuejs - the component is a fragment instance

    vuejs - the component is a fragment instance http://vuejs.org/guide/components.html#Fragment-Instanc ...

  5. andriod sdk模拟器安装过程中报错

    andriod sdk模拟器安装过程中,出现下述错误: Failed to fetch URL http://dl-ssl.google.com/android/repository/reposito ...

  6. SSM环境搭建(接口编程方式)

    一直用ssm在开发项目,之前都是直接copy别人的项目,今天趁着项目刚刚交付,自己搭建一下ssm环境,做个记录 一.创建项目.引入jar包,因为版本不一样,就不贴出这部分的内容了.个人平时的习惯是,先 ...

  7. 深入入门系列--Data Structure--04树

    终于有机会重新回头学习一下一直困扰自身多年的数据结构了,赶脚棒棒哒.一直以来,对数据结构的掌握基本局限于线性表,稍微对树有一丢丢了解,而对于图那基本上就是不懂(不可否认,很多的考试中回避了图也是原因之 ...

  8. 【WP 8.1开发】电子罗盘

    罗盘,估计也不用我过多介绍,学过初中物理的都知道,不管是指南针,还是指北针,其本质就是用来辨别方向的. 操作电子罗盘伟感器也不复杂,主要就是两个角度: 1.当前方向与磁北的夹角: 2.当前方向与地北的 ...

  9. WPF自定义控件与样式(11)-等待/忙/正在加载状态-控件实现

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要有三种实现方式 ...

  10. Ajax在IE浏览器会出现中文乱码解决办法

    在AJAX浏览器来进行发送数据时,一般它所默认的都是UTF-8的编码. Ajax在IE浏览器会出现中文乱码的情况!解决办法如下 <script type="text/javascrip ...