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>
#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的使用)的更多相关文章
- 2016弱校联盟十一专场10.3 We don't wanna work!
能把 not working now 写成 not working hard now 还查一晚上也是没谁了 我的做法是维护两个set 分别是前20% 和后80% #include<iostrea ...
- 2016弱校联盟十一专场10.3 We don't wanna work!
能把 not working now 写成 not working hard now 还查一晚上也是没谁了 我的做法是维护两个set 分别是前20% 和后80% #include<iostrea ...
- 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 ...
- 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 ...
- (2016弱校联盟十一专场10.3) D Parentheses
题目链接 把左括号看成A右括号看成B,推一下就行了.好久之前写的,推到最后发现是一个有规律的序列. #include <bits/stdc++.h> using namespace std ...
- (2016弱校联盟十一专场10.3) B.Help the Princess!
题目链接 宽搜一下就行. #include <iostream> #include<cstdio> #include<cstring> #include<qu ...
- (2016弱校联盟十一专场10.3) A.Best Matched Pair
题目链接 #include<cstdio> #include<cstring> #include<algorithm> #include<stack> ...
- 2016弱校联盟十一专场10.2---Around the World(深搜+组合数、逆元)
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem description In ICPCCamp, there ar ...
- (2016弱校联盟十一专场10.2) A.Nearest Neighbor Search
题目链接 水题,算一下就行. #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x[],y[], ...
随机推荐
- [源码解析]HashMap和HashTable的区别(源码分析解读)
前言: 又是一个大好的周末, 可惜今天起来有点晚, 扒开HashMap和HashTable, 看看他们到底有什么区别吧. 先来一段比较拗口的定义: Hashtable 的实例有两个参数影响其性能:初始 ...
- Atitit 全屏模式的cs桌面客户端软件gui h5解决方案 Kiosk模式
Atitit 全屏模式的cs桌面客户端软件gui h5解决方案 Kiosk模式 1.1. Kiosk Software广泛用于公共电脑或者嵌入系统,最常用的就是ATM机.自动服务机之类的系统了.,1 ...
- Android开发之注册登录
昨天给大家介绍了一下关于Android端向服务器端发送数据的方法,不过貌似有一点瑕疵,今天经过调试已经解决,在这里给大家介绍一下 貌似Android4.0以后版本的对于网络权限要求变得严格,导致昨天编 ...
- IIS 6中mimemap属性的默认设置
Collapse this tableExpand this table Extension MIME type .ra audio/x-pn-realaudio .sv4crc applicatio ...
- Net任意String格式转换为DateTime类型
方式一:Convert.ToDateTime(string) Convert.ToDateTime(string) 注意:string格式有要求,必须是yyyy-MM-dd hh:mm:ss 方式二: ...
- Yii2的深入学习--yii\base\Object 类
之前我们说过 Yii2 中大多数类都继承自 yii\base\Object,今天就让我们来看一下这个类. Object 是一个基础类,实现了属性的功能,其基本内容如下: <?php namesp ...
- [OpenCV] Samples 10: imagelist_creator
yaml写法的简单例子.将 $ ./ 1 2 3 4 5 命令的参数(代表图片地址)写入yaml中. 写yaml文件. 参考:[OpenCV] Samples 06: [ML] logistic re ...
- PetaPoco 访问SQL SERVER 存储过程
博客园有篇文章<小巧方便的ORM类库——PetaPoco> 介绍了PetaPoco调用存储过程: //调用存储过程 db.Execute("exec procSomeHandl ...
- 牛顿法与拟牛顿法学习笔记(三)DFP 算法
机器学习算法中经常碰到非线性优化问题,如 Sparse Filtering 算法,其主要工作在于求解一个非线性极小化问题.在具体实现中,大多调用的是成熟的软件包做支撑,其中最常用的一个算法是 L-BF ...
- Tools - 国内开源镜像网站
阿里云镜像 网易开源镜像站 搜狐开源镜像站 香港中文大学 清华大学开源软件镜像站 中国科学技术大学开源软件镜像 中国互联网络信息中心开源镜像站 - apache开源软件镜像