2016弱校联盟十一专场10.3,BNU52308,大模拟

Posted by Cww97 on 2016-10-04

版权声明:本文为博主原创文章,未经博主允许不得转载。原文所在http://blog.csdn.net/cww97 https://blog.csdn.net/cww97/article/details/52730834
大模拟
时限60s
你没有看错
是s不是ms

https://www.bnuoj.com/v3/problem_show.php?pid=52308

开两个set
一个是前面20%
一个是后面80%
然后就在两个set的边界处操作
= =
操作,好烦啊啊啊啊啊啊啊啊 啊啊啊

还有种写法是开两个map类似

无论哪一种,代码量都大的可怕= =
HH用map写了150行
cdm用map写了200行(听说4个map)

从下午四点开始写
一开始用map写,写了100+行,样例调了半天,秒WA
调到10点,气哭
后来听zm说可以用两个set,似乎好写一点
然后再写,再WA,再换写法,再发现之前少了一句。。。
终于,发现评测机跑了10s以上基本就是过了
不是因为网速卡,因为,时限有60s= =!

以后写模拟题还是要细心啊,诶,好累

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <set>
#include <map>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100007;
struct node{
string name;
int val,time;
void read(int x){time = x;cin>>name>>val;}
bool operator < (const node &a)const{
return val!=a.val?val>a.val:time>a.time;
}
}arr[N];
int n;
map<string,int>val;
map<string,int>tim;
set <node> work;
set <node> rest;
set<node>::iterator it;
void newGuy(string st,int time){
n++;
int x;scanf("%d",&x);
node tmp,newguy = node{st,x,time};
val[st] = x; tim[st] = time ;
it=rest.begin(); tmp = (*it);
if ((work.size()+1)*5<=n){
if (newguy<tmp){
work.insert(newguy);
cout<<newguy.name<<" is working hard now."<<endl;
}else {
rest.insert(newguy);
cout<<newguy.name<<" is not working now."<<endl;
rest.erase(tmp);
work.insert(tmp);
cout<<tmp.name<<" is working hard now."<<endl;
}
}else {
if (work.empty()){
rest.insert(newguy);
cout<<newguy.name<<" is not working now."<<endl;
}else {
it = work.end(); it--;
tmp = (*it);
if (newguy<tmp){
work.insert(newguy);
work.erase(tmp);
rest.insert(tmp);
cout<<newguy.name<<" is working hard now."<<endl;
cout<<tmp.name<<" is not working now."<<endl;
}else {
rest.insert(newguy);
cout<<newguy.name<<" is not working now."<<endl;
}
}
}
}
void leave(string st){
n--;
node tmp,leaveguy=node{st,val[st],tim[st]};
if (work.find(leaveguy)!=work.end()){
work.erase(leaveguy);
if ((work.size()+1)*5<=n){
it = rest.begin();
tmp = (*it);
rest.erase(tmp);
work.insert(tmp);
cout<<tmp.name<<" is working hard now."<<endl;
}
}else {
rest.erase(leaveguy);
if ((work.size()+1)*5<=n){
it = rest.begin();
tmp = (*it);
rest.erase(tmp);
work.insert(tmp);
cout<<tmp.name<<" is working hard now."<<endl;
}else if (work.size()*5>n&&!work.empty()){
it = work.end();it--;
tmp = (*it);
work.erase(tmp);
rest.insert(tmp);
cout<<tmp.name<<" is not working now."<<endl;
}
}
}
int main(){
for (int m;cin>>n;){
work.clear() ;
rest.clear() ;
for (int i=1;i<=n;i++) arr[i].read(i-n);
sort( arr+1, arr+n+1) ;
for (int i=1;i<=n;i++){
node tmp = arr[i];
val[tmp.name] = tmp.val ;
tim[tmp.name] = tmp.time;
if (i<=(int)(n/5.0))work.insert(arr[i]);
else rest.insert(arr[i]);
}
char ch;string st;
scanf("%d",&m);
for (int i=1;i<=m;i++){
cin>>ch>>st;
if (ch=='+')newGuy(st,i);
else leave(st);
}
}
return 0;
}