import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
while (!"0".equals(line.trim()))
{
String[] ss = line.split(" ");
int size = Integer.parseInt(ss[0]);
int away = 0;
int capacity = 0;
char[] array = new char[size];
for (char c : ss[1].toCharArray())
{
boolean finish = false;
for (int i = 0; i < array.length; i++)
{
if (array[i] == c)
{
array[i] = 0;
capacity--;
finish = true;
break;
}
}
if (finish)
continue;
if (capacity < size)
{
for (int i = 0; i < array.length; i++)
{
if (array[i] == 0)
{
array[i] = c;
capacity++;
break;
}
}
}
else
{
away++;
}
}
if (away == 0)
System.out.println("All customers tanned successfully.");
else
System.out.println(away / 2 + " customer(s) walked away.");
line = sc.nextLine();
}
}
}
ZOJ-1405
最新推荐文章于 2014-08-09 11:03:12 发布