2016弱校联盟十一专场10.3 We don't wanna work!
来源:互联网 发布:网络与新媒体和传播学 编辑:程序博客网 时间:2024/06/05 04:25
能把 not working now 写成 not working hard now
还查一晚上也是没谁了
我的做法是维护两个set 分别是前20% 和后80%
#include<iostream>#include<algorithm>#include<set>#include<cmath>#include<map>#include<cstdio>using namespace std;#define sz(X) ((int)X.size())int N,M;char nam[70005][25];map<string, int> mp;struct Node{ int id; int val; int ti; Node(int a=0, int b=0, int c=0):id(a),val(b),ti(c){} bool operator < (const Node &v) const{ if(val != v.val) return val > v.val; return ti > v.ti; } bool operator == (Node v) const{ return id==v.id && val==v.val && ti==v.ti; }}mem[70005];set<Node> s1; set<Node> s2;set<Node>::iterator it1,it,it2;int main(){ while(~scanf("%d",&N)) { mp.clear(); s1.clear(); s2.clear(); for(int i = 0; i < N; ++i) { int a; scanf("%s %d",nam[i], &a); s2.insert(Node(i,a,i)); mem[i] = Node(i,a,i); mp[nam[i]] = i; } int tot = N; int K = floor(N/5); while(K--) { it = s2.begin(); Node y = *it; s2.erase(y); s1.insert(y); } scanf("%d",&M); for(int i = N; i < N+M; ++i) { char s[5]; scanf("%s",s); if(s[0] == '+') { int a; scanf("%s %d",nam[i],&a); Node tt = Node(i,a,i); mem[i] = tt; mp[nam[i]] = i; tot ++; int x = floor(tot/5); int y = tot-x; if(sz(s2) == y-1) { s1.insert(tt); it = --s1.end(); Node t2 = *it; s1.erase(it); if(t2 == tt) { printf("%s is not working now.\n",nam[i]); s2.insert(t2); }else { printf("%s is working hard now.\n",nam[i]); printf("%s is not working now.\n",nam[t2.id]); s2.insert(t2); } }else { s2.insert(tt); it = s2.begin(); Node t2 = *it; s2.erase(it); if(t2 == tt) { printf("%s is working hard now.\n",nam[i]); s1.insert(t2); }else { printf("%s is not working now.\n",nam[i]); printf("%s is working hard now.\n",nam[t2.id]); s1.insert(t2); } } }else if(s[0] == '-') { char _s[25]; scanf("%s",_s); Node tt = mem[mp[_s]]; it1 = s1.find(tt); it2 = s2.find(tt); if(it1 != s1.end()) s1.erase(it1); else s2.erase(it2); tot--; int x = floor(tot/5); int y = tot-x; if(sz(s1) > x) { it = --s1.end(); Node t2 = *it; printf("%s is not working now.\n",nam[t2.id]); s1.erase(it); s2.insert(t2); } if(sz(s2) > y) { it = s2.begin(); Node t2 = *it; printf("%s is working hard now.\n",nam[t2.id]); s2.erase(it); s1.insert(t2); } } } } return 0;}
0 0
- 2016弱校联盟十一专场10.3 C.We don't wanna work!(集合操作)
- 2016弱校联盟十一专场10.3 We don't wanna work!
- BNUOJ 52308 2016弱校联盟 10月3日场 We don’t wanna work! 双set维护 模拟
- We don't wanna work! STL应用
- JAG Practice2016-C-We don't wanna work!-模拟
- bnu52308 We don't wanna work! 【模拟+set】
- 2016弱校联盟十一专场10.3(12点场)
- 2016弱校联盟十一专场10.3,BNU52308,大模拟
- 2016弱校联盟十一专场10.2 Longest Increasing Subsequence
- [Contests]2016弱校联盟十一专场10.7
- Blocks(弱校联盟十一专场)
- UmBasketella(弱校联盟十一专场)
- 2016弱校联盟十一专场10.3 ABest Matched Pair(水)
- (2016 弱校联盟十一专场10.3) Similarity of Subtrees DFS + hash
- Don't Wanna Try
- (2016弱小联盟十一专场10.3)Parentheses 找规律
- (2016弱小联盟十一专场10.3) Best Matched Pair 暴力
- Parentheses(弱校联盟十一专场)字典序
- ubuntu无网卡使用360wifi 联网
- 机器学习之六:神经网络
- Proxy实现CXF客户端
- 数据库批处理操作-mysql-sqlite
- {福利}常用算法复杂度
- 2016弱校联盟十一专场10.3 We don't wanna work!
- 面向对象_多态中的成员访问特点
- Fay的内存分析
- 一点感想
- Spring及J2EE常用注解
- 统计一个字符串中单词的个数(C语言)
- Greenplum的一些资源
- 策略模式简介
- 设计模式-简单工厂设计模式