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[], ...
随机推荐
- fir.im Weekly - Mobile developer 利器分享
工欲善其事,必先利其器.本期 fir.im Weekly 推荐了很多优秀的 Github 项目.iOS/Android 开发工具利器,比如墨__守独立开发的macOS App -- Repo, 帮助 ...
- flow.ci + Github + Slack 一步步搭建 Python 自动化持续集成
理想的程序员必须懒惰,永远追随自动化法则.Automating shapes smarter future. 在一个 Python 项目的开发过程中可能会做的事情:编译.手动或自动化测试.部署环境配置 ...
- Spring-JDBC实现Contact的CRUD
Spring-JDBC完成Contact的CRUD. 两点注意: 1.log4j.properties文件不能少 2.注意导入的包之间的依赖关系以及版本要求. 项目结构: 主要文件: 建表脚本: CR ...
- jquery 之 Deferred 使用与实现
观察者模式是开发中经常使用的模式,这个模式由两个主要部分组成:主题和观察者.通过观察者模式,实现主题和观察者的解耦. 主题负责发布内容,而观察者则接收主题发布的内容.通常情况下,观察者都是多个,所以, ...
- 利用奇异值分解(SVD)简化数据
特征值与特征向量 下面这部分内容摘自:强大的矩阵奇异值分解(SVD)及其应用 特征值分解和奇异值分解在机器学习领域都是属于满地可见的方法.两者有着很紧密的关系,在接下来会谈到,特征值分解和奇异值分解的 ...
- 处于同一个域中的两台Sql server 实例无法连接
处于同一个域中的两台Sql server 实例无法连接,报的错误信息如下: A network-related or instance-specific error occurred while es ...
- C#相关
1.索引器 索引器允许类或结构的实例按照与数组相同的方式进行索引.索引器类似于属性,不同之处在于它们的访问器采用参数.它可以像数组那样对对象使用下标.它提供了通过索引方式方便地访问类的数据信息的方法. ...
- Comet服务器推送与SignalR
HTTP协议是一个典型的Request/Response协议,是基于TCP/IP之上的一个应用层协议,该协议最典型的特点就是无状态且需要客户端发起Request服务端才能进行Response, ...
- 通过js获得选择文件的绝对路径
<form name="thisform" method="get" action="test.jsp" id="thisf ...
- Codeforces Round #277(Div. 2) (A Calculating Function, B OR in Matrix, C Palindrome Transformation)
#include<iostream> #include<cstring> #include<cstdio> /* 题意:计算f(n) = -1 + 2 -3 +4. ...