-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4094.cpp
More file actions
executable file
·44 lines (41 loc) · 1.05 KB
/
Copy path4094.cpp
File metadata and controls
executable file
·44 lines (41 loc) · 1.05 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
43
44
/**
* 模拟题
* 注意 顾客第一次没床位第二次也不会进来...
* 理解题意5555
**/
#include <iostream>
#include <cstring>
using namespace std;
int num, cnt, cur;
char cus[100];
int in[30], lef[30];
int main() {
while(1) {
scanf("%d", &num);
if(num == 0) break;
cnt = 0; cur = 0;
for(int i = 0;i < 30;++ i) {
in[i] = 0;
lef[i] = 0;
}
scanf("%s", cus);
for(int i = 0;i < strlen(cus);++ i) {
if(in[cus[i] - 'A']) {
in[cus[i] - 'A'] = 0;
-- cur;
} else {
if(cur < num) {
if(lef[cus[i] - 'A']) continue;
in[cus[i] - 'A'] = 1;
++ cur;
}
else {
if(! lef[cus[i] - 'A']) ++ cnt;
lef[cus[i] - 'A'] = 1;
}
}
}
if(cnt) printf("%d customer(s) walked away.\n", cnt);
else printf("All customers tanned successfully.\n");
}
}