-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2015j4.c
More file actions
42 lines (42 loc) · 1.06 KB
/
2015j4.c
File metadata and controls
42 lines (42 loc) · 1.06 KB
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
#include <stdio.h>
int friendwaittotal[101];
int friendpresent[101];
int friendstatus[101];
int main(){
int m,i,texttime=0;
int friendid;
char action;
scanf("%d\n",&m);
for(i=0;i<m;i++){
if(i==m-1){
scanf("%c %d",&action,&friendid);
}else{
scanf("%c %d\n",&action,&friendid);
}
if(action=='R'){
friendstatus[friendid]=texttime;
texttime++;
friendpresent[friendid]=1;
}else if(action=='S'){
friendwaittotal[friendid]+=texttime-friendstatus[friendid];
friendstatus[friendid]=0;
texttime++;
}else{
texttime+=friendid-1;
}
}
for(i=1;i<=100;i++){
if(friendpresent[i]){
if(friendstatus[i]==0){
if(friendwaittotal[i]!=0){
printf("%d %d\n",i,friendwaittotal[i]);
}else{
printf("%d -1\n",i);
}
}else{
printf("%d -1\n",i);
}
}
}
return 0;
}