We don't wanna work!
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!的更多相关文章
- 题目1162:I Wanna Go Home(最短路径问题进阶dijkstra算法))
题目链接:http://ac.jobdu.com/problem.php?pid=1162 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- A - I Wanna Be the Guy
Problem description There is a game called "I Wanna Be the Guy", consisting of n levels. L ...
- 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 ...
- When you want to succeed as bad as you wanna breathe, then you’ll be successful.
上周末登了次山,回来就各种矫情犯懒.今天周四一周又要完蛋,我发现自己真的是对时间流逝无可奈何.然后中午看了把小码哥网站还有MJ博客什么的,各种首期班大爆照,心中羞愧无比.年纪大也不能放弃自己啊,要不人 ...
- 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> # ...
随机推荐
- spring boot redis 缓存(cache)集成
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- Spring框架之一 读取配置文件
以下代码都是来源于官方源码(Spring-4.3.18.RELEASE),此处只是为自己以后深啃先布局出大概流程,请各看官不要浪费时间看 说明: .. 表示省略代码, // 后的如果不是源码自带则为当 ...
- 寒假day18
今天完成了人才动态模块的数据爬取
- java使用mongoTemplate去重排序查询
import org.springframework.data.mongodb.core.MongoTemplate;import org.springframework.data.mongodb.c ...
- 转载:Apache优化:修改最大并发连接数
本文转自:https://blog.csdn.net/bjash/article/details/50394894 Apache是一个跨平台的web服务器,由于其简单.稳定安全的特性,被广泛应用于计算 ...
- python中ndarray和matrix
1. 定义ndarray和matrix from numpy import * a = mat([[1,2],[3,4]]) b = mat([[5,6],[7,8]]) c = array([1,2 ...
- vi_终端中的编辑器操作
vi -- 终端中的编辑器 目标 vi 简介 打开和新建文件 三种工作模式 常用命令 分屏命令 常用命令速查图 01. vi 简介 1.1 学习 vi 的目的 在工作中,要对 服务器 上的文件进行 简 ...
- thinkcmf2.2 火狐浏览器图片上传以及谷歌图片上传打开稍慢
对目录中 admin/themes/simplebootx/asset/plupload.html 文件 进行更改如下图:
- springboot +Thymeleaf+UEditor整合记录
1,ueditor官网下载:https://ueditor.baidu.com/website/download.html 下载相应的工具包和源码,ps:源码放到工程中 2,解压放到放到项目中,sp ...
- git submodule update --init 和 --remote的区别
git 的submodule 工具方便第三方库的管理,比如gitlab 上的各种开源工具,spdlog等 在项目目录下创建.gitmodule 里可以添加第三方库,然后在更新第三方库时,有两个选项 g ...