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[], ...
随机推荐
- NodeJS系列~第四个小例子,NodeJs处理Get请求和Post请求
返回目录 说在前 对于HTTP请求来说,我们通常使用的是Get和Post,除此之外还有put,delete等,而对于get来说,比较lightweight,只是对字符串的传输,它会被添加到URL地址里 ...
- atitit..代码生成流程图 流程图绘制解决方案 java c#.net php v2
atitit..代码生成流程图 流程图绘制解决方案 java c#.net php v2 1.1. Markdown 推荐,就是代码和flow都不能直接使用.1 1.2. Java code2fl ...
- Java EE开发平台随手记1
过完春节以来,一直在负责搭建公司的新Java EE开发平台,所谓新平台,其实并不是什么新技术,不过是将目前业界较为流行的框架整合在一起,做一些简单的封装和扩展,让开发人员更加易用. 和之前负责具体的项 ...
- 【WP 8.1开发】一键锁屏
在WP8的时候,关于如何关闭屏幕,国内外都有不少文章了,大家有兴趣地可以搜搜,很多,我就不给链接了,因为稍后我的例子中会有. 其实,关闭屏幕是调用了未开放的API,正因为这个API未开放的,不敢保证所 ...
- 【WP 8.1开发】如何处理摄像头翻转的问题
模拟器就像我们儿时的梦境,在其上运行应用程序时,一切总是那么美好的:而真机测试如同我们这个纷乱无章的现实世界,你会遇到各种小人和畜生,常常会遭受莫名的挫折.面对挫折,有人迎难而上,或不予理采,走自己的 ...
- MIME参考列表
定义 MIME(multipurpose internet mail extensions)多用途互联网邮件扩展类型是描述消息内容类型的因特网标准.MIME消息能包含文本.图像.音频.视频以及其他应用 ...
- js实现图片加载特效(从左到右,百叶窗,从中间到两边)
/* 网上百度的,感觉”从中间到两边“的效果写的不是很好,改了一下,感觉可以了!*/<html> <head> <title></title> < ...
- 后端码农谈前端(CSS篇)第五课:CSS样式
一.背景: CSS 允许应用纯色作为背景,也允许使用背景图像创建相当复杂的效果. 1.背景色 可以使用 background-color 属性为元素设置背景色.这个属性接受任何合法的颜色值. 例如: ...
- Sparse Filtering 学习笔记(一)网络结构与特征矩阵
Sparse Filtering 是一个用于提取特征的无监督学习算法,与通常特征学习算法试图建模训练数据的分布的做法不同,Sparse Filtering 直接对训练数据的特征分布进行分析,在所谓 ...
- REST API出错响应的设计
REST API应用很多,一方面提供公共API的平台越来越多,比如微博.微信等:一方面移动应用盛行,为Web端.Android端.IOS端.PC端,搭建一个统一的后台,以REST API的形式提供服务 ...