能把 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. java中String、包装类、枚举类的引用传递

    一般情况下,我们认为Java中了除了八种基本数据类型,其他都是对象,进行引用传递: 但是:String.包装类.枚举类作为参数传递后发现,没有达到引用传递的效果,很多人认为它是值传递! 首先,对象肯定 ...

  2. AngularJS 控制器函数

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  3. 课时60.CSS的固定格式(掌握)

    CSS就是用来设置样式的,美化界面的 如何验证? 打开一个京东首页 删除掉css样式 发现页面变得非常难看 由此我们验证了一个说法,css就是用来美化界面的 1.格式: <style type= ...

  4. ACL常用命令及工作原理

    What ACL 是一系列 IOS 命令,根据数据包报头中找到的信息来控制路由器应该转发还是应该丢弃数据包.ACL 是思科 IOS 软件中最常用的功能之一. 在配置后,ACL 将执行以下任务: 限制网 ...

  5. 不使用C++ 11的整数转字符串

    蓝桥杯不支持C++11,那么to_string方法就用不了了.C语言提供了一种方法. 首先需要头文件 #include <sstream> 然后进行下面的操作就可以,缺点就是比较耗时. # ...

  6. leetcode笔记(三)207. Course Schedule

    题目描述(原题目链接) There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may ...

  7. VMware ESXi-6.7——使用

    1: 上传ISO文件 1.1:创建一个新目录,上传ISO 1.2: 在新建虚拟机时,点击DVD,选择数据ISO文件,选择要安装的ISO文件.并把连接打钩. 2:新建虚拟机 按照需求填写 硬盘的三种置备 ...

  8. PostgreSQL数据库的安装

    1 总体规划 操作系统 CentOS Linux release 7.5.1804 处理器 1 内存 4G 硬盘 38G 主机名称 chenzx IP地址 192.168.56.8 1.1 用户组和用 ...

  9. Golang定时器断续器

    定时器 1.定时器结构 结构定义 type Timer struct { C <-chan Time // 接受定时器事件的通道 r runtimeTimer } type runtimeTim ...

  10. CentOS7下PHP7.2安装redis扩展

    1.安装phpize(存在忽略) yum install php-devel 2.下载扩展源码包,直接用wget,一般放在 /usr/local/src wget https://github.com ...