We don't wanna work!

[JAG Asia 2016]

两个set,一个代表工作的,一个代表不工作的

其实是一个很简单的模拟,但是我竟然排序之前标号。。。。

检查代码的时候要从头开始检查。。

#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5+7;
struct node
{
char s[25];
int ti,fen;
bool operator<(const node&r)const
{
if(fen==r.fen)
{
return ti>r.ti;
}
return fen>r.fen;
}
} s[maxn],tmp;
set<node>st,stt;
set<node>::iterator it;
map<string,int>mp;
char str[25];
char op[5];
int p;
void solve()
{
if(st.size()>p)
{
it=st.end();
--it;
tmp=*it;
cout<<tmp.s<<" is not working now."<<endl;
st.erase(tmp);
stt.insert(tmp);
}
else if(st.size()<p)
{
it=stt.begin();
tmp=*it;
cout<<tmp.s<<" is working hard now."<<endl;
stt.erase(tmp);
st.insert(tmp);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
int cnt=0,tag=0,k;
p=n*0.2;
for(int i=1; i<=n; ++i)
{
cin>>s[i].s>>k;
s[i].fen=k;
s[i].ti=i;
}
sort(s+1,s+1+n);
for(int i=1; i<=n; ++i)
{
mp[s[i].s]=++cnt;
tag++;
if(i<=p)
{
st.insert(s[i]);
}
else
{
stt.insert(s[i]);
}
}
int m;
cin>>m;
int id;
while(m--)
{
cin>>op;
tag++;
if(op[0]=='+')
{
n++;
p=n*0.2;
cin>> str>>k;
if(mp.count(str))
{
id=mp[str];
s[id].ti=tag;
s[id].fen=k;
}
else
{
mp[str]=++cnt;
s[cnt].fen=k;
s[cnt].ti=tag;
strcpy(s[cnt].s,str);
id=cnt;
}
if(st.empty())
{
if(p>0&&k>=(*stt.begin()).fen)
{
st.insert(s[id]);
cout<<s[id].s<<" is working hard now."<<endl;
}
else
{
stt.insert(s[id]);
cout<<s[id].s<<" is not working now."<<endl;
}
}
else
{
it=st.end();
--it;
if(k>=(*it).fen||(st.size()<p&&k>=(*stt.begin()).fen))
{
st.insert(s[id]);
cout<<s[id].s<<" is working hard now."<<endl;
}
else
{
stt.insert(s[id]);
cout<<s[id].s<<" is not working now."<<endl;
}
}
solve();
}
else
{
n--;
p=n*0.2;
cin>>str;
id=mp[str];
if(st.find(s[id])!=st.end())
{
st.erase(s[id]);
}
else
{
stt.erase(s[id]);
}
solve();
}
}
return 0;
}

We don't wanna work!的更多相关文章

  1. 题目1162:I Wanna Go Home(最短路径问题进阶dijkstra算法))

    题目链接:http://ac.jobdu.com/problem.php?pid=1162 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  2. BNUOJ 52308 We don't wanna work! set模拟

    题目链接: https://acm.bnu.edu.cn/v3/problem_show.php?pid=52308 We don't wanna work! Time Limit: 60000msM ...

  3. HDU 5308 I Wanna Become A 24-Point Master(2015多校第二场)

    I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 ...

  4. 2015多校联合训练赛 hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2 构造题

    I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 ...

  5. HDU 5308 I Wanna Become A 24-Point Master

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5308 题面: I Wanna Become A 24-Point Master Time Limit ...

  6. A - I Wanna Be the Guy

    Problem description There is a game called "I Wanna Be the Guy", consisting of n levels. L ...

  7. 2015 Multi-University Training Contest 2 hdu 5308 I Wanna Become A 24-Point Master

    I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 ...

  8. When you want to succeed as bad as you wanna breathe, then you’ll be successful.

    上周末登了次山,回来就各种矫情犯懒.今天周四一周又要完蛋,我发现自己真的是对时间流逝无可奈何.然后中午看了把小码哥网站还有MJ博客什么的,各种首期班大爆照,心中羞愧无比.年纪大也不能放弃自己啊,要不人 ...

  9. 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> # ...

随机推荐

  1. 【转】TransactionScope事务处理方法介绍及.NET Core中的注意事项

    什么是TransactionScope呢? TransactionScope作为System.Transactions的一部分被引入到.NET 2.0.同时SqlClient for .NET Cor ...

  2. h5页面乱码-设置编码

    1.h5页面正常,重定向以后出现乱码,如图所示. 解决办法:重定向的时候 需要设置编码. 2.文件charset已经是utf-8,页面还是乱码,文件保存的格式也要是utf-8的哦

  3. nginx log 切割

    /logs/nginx/*/*access.log { daily rotate 30 missingok dateext #compress notifempty sharedscripts pos ...

  4. android studio 黑屏问题

    AVD配置不对,打开AVD从新配置

  5. LCIS HDU - 3308 (线段树区间合并)

    LCIS HDU - 3308 Given n integers. You have two operations: U A B: replace the Ath number by B. (inde ...

  6. tensorflow 分布式训练

    TF实现分布式流程 1.创建集群 ClusterSpec & Server cluster = tf.train.ClusterSpec({"ps": ps_hosts, ...

  7. 27. docker compose 单机 均衡负载

    1.编写Dockerfile #Dockerfile FROM python:2.7 LABEL maintaner="eaon eaon123@docker.com" COPY ...

  8. BZOJ 4913 [Sdoi2017] 遗忘的集合

    骂了隔壁的 BZOJ垃圾评测机 我他妈卡了两页的常数了 我们机房的电脑跑的都比BZOJ快

  9. 在WSL Ubuntu1804中安装Docker

    一.系统环境 1.1 环境准备: Windows10 企业版 1909 Docker for Windows WSL Ubuntu1804 1.2 下载安装 Docker for Windows 1. ...

  10. Java连载71-二分查找和Arrays工具类

    一.二分法查找 1.二分法查找是建立在已经排序的基础之上的 2.程序分析是从下到大​排序. 3.这个数组中没有重复的元素​. package com.bjpowernode.java_learning ...