Submission #01523


ソースコード

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
#include<bits/stdc++.h>
#define F first
#define S second
#define RIGHT d.size()-1
#define LEFT 0
using namespace std;
typedef pair<int,int> P;
typedef pair<string, P > SPP;
main(){
deque<SPP> d;
d.clear();
int k;//k=命令の数
char a;
string b;
int c;
int chear[1001];//番地人用の椅子の数
int kaiten;
int isu;
queue<int> noweat;
cin>>k>>kaiten>>isu;
for(int i=1;i<=isu;i++){
cin>>chear[i];
}
for(int i=0;i<k;i++){
cin>>a>>b>>c;
if(a=='L'){//左に並ぶ
if(d.size()>0&&d[LEFT].F==b&&d[LEFT].S.F==c){
d[LEFT].S.S++;
}
else{
d.push_front(SPP(b,P(c,1)));
}
}
else if(a=='R'){//右に並ぶ
if(d.size()>0&&d[RIGHT].F==b&&d[RIGHT].S.F==c){
d[RIGHT].S.S++;
}
else{
d.push_back(SPP(b,P(c,1)));
}
}
else if(a=='C'){//Call
int mpos=-1;
for(int i=0;i<d.size()&&mpos==-1;i++){
if(d[i].F==b&&d[i].S.F==c){
mpos=i;
}
}
if(mpos!=-1&&d[mpos].S.S>=c&&chear[c]>0){//座れる
chear[c]--;
deque<SPP>::iterator it=d.begin()+mpos;
d.erase(it);
noweat.push(c);
if(mpos!=0&&mpos!=d.size()&&d[mpos].F==d[mpos-1].F&&d[mpos].S.F==d[mpos-1].S.F){//結合
d[mpos-1].S.S+=d[mpos].S.S;
it=d.begin()+mpos;
d.erase(it);
}
if(noweat.size()>kaiten){
chear[noweat.front()]++;
noweat.pop();
}
}
}
}
if(!d.empty()){
for(int j=0;j<d.size();j++){
cout<<d[j].F<<","<<d[j].S.F<<","<<d[j].S.S<<endl;
}
}
else{
cout<<"Perfect"<<endl;
}
}

ステータス

項目 データ
問題 0165 - お詫びの準備
ユーザー名 ei1417
投稿日時 2015-10-28 16:26:47
言語 C++11
状態 Accepted
得点 1
ソースコード長 1583 Byte
最大実行時間 554 ms
最大メモリ使用量 6476 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
DangerInput1.txt AC 441 ms 732 KB
1
DangerInput2.txt AC 554 ms 6476 KB
1
DangerInput3.txt AC 441 ms 1924 KB
1
MyInput1.txt AC 11 ms 1852 KB
1
MyInput2.txt AC 11 ms 1816 KB
1
MyInput3.txt AC 10 ms 1916 KB
1
MyInput4.txt AC 10 ms 2020 KB
1
MyInput5.txt AC 12 ms 1988 KB
1
OmiseInput1.txt AC 14 ms 1956 KB
1
OmiseInput2.txt AC 11 ms 2424 KB
1
OmiseInput3.txt AC 13 ms 2524 KB
1
OmiseInput4.txt AC 11 ms 2620 KB
1
OmiseInput5.txt AC 16 ms 2464 KB
1
OmiseInput6.txt AC 13 ms 2560 KB
1
OmiseInput7.txt AC 13 ms 2524 KB
1
OmiseInput8.txt AC 16 ms 2484 KB
1
OmiseInput9.txt AC 14 ms 2448 KB
1
OmiseInput10.txt AC 14 ms 1928 KB
1
OmiseInput11.txt AC 282 ms 2272 KB
1
OmiseInput12.txt AC 250 ms 2224 KB
1
OmiseInput13.txt AC 435 ms 2760 KB
1
OmiseInput14.txt AC 244 ms 2564 KB
1
OmiseInput15.txt AC 486 ms 2756 KB
1
SampleInput1.txt AC 11 ms 2408 KB
1
SampleInput2.txt AC 14 ms 2380 KB
1
SampleInput3.txt AC 10 ms 2480 KB
1
SampleInput4.txt AC 14 ms 2452 KB
1