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

#include<iostream>
#include<algorithm>
#include<set>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define sz(X) ((int)X.size())
int N,M;
char nam[70005][25];
map<string, int> mp;
struct Node{
int id; int val; int ti;
Node(int a=0, int b=0, int c=0):id(a),val(b),ti(c){}
bool operator < (const Node &v) const{
if(val != v.val) return val > v.val;
return ti > v.ti;
}
bool operator == (Node v) const{
return id==v.id && val==v.val && ti==v.ti;
}
}mem[70005];
set<Node> s1; set<Node> s2;
set<Node>::iterator it1,it,it2; int main(){
while(~scanf("%d",&N)) {
mp.clear();
s1.clear(); s2.clear();
for(int i = 0; i < N; ++i) {
int a; scanf("%s %d",nam[i], &a);
s2.insert(Node(i,a,i));
mem[i] = Node(i,a,i);
mp[nam[i]] = i;
}
int tot = N;
int K = floor(N/5);
while(K--) {
it = s2.begin();
Node y = *it;
s2.erase(y);
s1.insert(y);
} scanf("%d",&M);
for(int i = N; i < N+M; ++i) {
char s[5]; scanf("%s",s);
if(s[0] == '+') {
int a; scanf("%s %d",nam[i],&a);
Node tt = Node(i,a,i);
mem[i] = tt; mp[nam[i]] = i;
tot ++;
int x = floor(tot/5); int y = tot-x; if(sz(s2) == y-1) {
s1.insert(tt);
it = --s1.end(); Node t2 = *it; s1.erase(it);
if(t2 == tt) {
printf("%s is not working now.\n",nam[i]);
s2.insert(t2);
}else {
printf("%s is working hard now.\n",nam[i]);
printf("%s is not working now.\n",nam[t2.id]);
s2.insert(t2);
}
}else {
s2.insert(tt);
it = s2.begin(); Node t2 = *it; s2.erase(it);
if(t2 == tt) {
printf("%s is working hard now.\n",nam[i]);
s1.insert(t2);
}else {
printf("%s is not working now.\n",nam[i]);
printf("%s is working hard now.\n",nam[t2.id]);
s1.insert(t2);
}
} }else if(s[0] == '-') {
char _s[25];
scanf("%s",_s);
Node tt = mem[mp[_s]];
it1 = s1.find(tt); it2 = s2.find(tt);
if(it1 != s1.end()) s1.erase(it1);
else s2.erase(it2);
tot--;
int x = floor(tot/5); int y = tot-x;
if(sz(s1) > x) {
it = --s1.end(); Node t2 = *it;
printf("%s is not working now.\n",nam[t2.id]);
s1.erase(it); s2.insert(t2);
}
if(sz(s2) > y) {
it = s2.begin(); Node t2 = *it;
printf("%s is working hard now.\n",nam[t2.id]);
s2.erase(it); s1.insert(t2);
} }
}
}
return 0;
}

2016弱校联盟十一专场10.3 We don't wanna work!的更多相关文章

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

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

  2. 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 ...

  3. 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 ...

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

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

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

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

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

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

  7. 2016弱校联盟十一专场10.3---We don't wanna work!(STL--set的使用)

    题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/C 代码如下: #include <iostream> # ...

  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. LOJ #116 有源汇点有上下界的最大流

    先连一条从汇点到源点的容量为INF的边,将其转化成无源汇点有上下界的可行流,判断是否可行 若可行的话删掉超级源点和超级汇点,再跑一遍最大流即可 #include <iostream> #i ...

  2. BZOJ 1202: [HNOI2005]狡猾的商人 [带权并查集]

    题意: 给出m个区间和,询问是否有区间和和之前给出的矛盾 NOIp之前做过hdu3038..... 带权并查集维护到根的权值和,向左合并 #include <iostream> #incl ...

  3. [Python Study Notes]批量将wold转换为pdf

    本文代码,由原ppt2pdf.py进行改写 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  4. 【Tools】linux更改分辨率,解决虚拟机安装后太小的问题

    Linux更改屏幕分辨率 1,分辨率模式已存在 1)如何查询是否存在: 终端输入命令:xrandr,即会输出当前已存在的分辨率模式. 2)如何配置: 使用命令xrandr --output 显示器名称 ...

  5. ASP.NET MVC5+EF6+EasyUI 后台管理系统(89)-EF执行SQL语句与存储过程

    这一节,我们来看看EF如何执行SQL语句与读取存储过程的数据,可能有一部分人,还不知道EF如何执行存储过程与原生SQL语句! 我们什么时候要直接使用原生的SQL语句? 返回值过于复杂 过于复杂的联合查 ...

  6. [记录]一则清理MySQL大表以释放磁盘空间的案例

    一则清理MySQL大表以释放磁盘空间的案例 一.基本情况: 1.dbtest库554G,先清理st_online_time_away_ds(37G)表的数据,保留半年的数据: 1)删除的数据:sele ...

  7. 【学习笔记】Hibernate HQL连接查询和数据批处理 (Y2-1-7)

    HQL连接查询 和SQL查询一样 hql也支持各种链接查询 如内连接 外连接 具体如下 左外连接 left (outer) join 迫切左外连接 left (outer) join fetch 右外 ...

  8. Linux下ACL权限控制以及用sudo设置用户对命令的执行权限

    ACL权限分配 1.setfacl命令设置文件权限 setfacl -m u:user1:rw root.txt setfacl -m u:user2:rwx root.txt 2.getfacl命令 ...

  9. Java多维数组各轴长度可以不对齐

  10. windows 如何编译 Openssl ?

    windows 如何编译 Openssl ? 编译环境 VS2015 Openssl 1.0.2 ActivePerl 5.24.3 x64 编译步骤 安装 ActivePerl 期间,勾选添加至环境 ...