您的位置:首页 > 其它

poj 1250 Tanning Salon

2012-06-05 19:23 232 查看
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

vector<char> v;
vector<char>::iterator it;

int main()
{
int customers, i, len, ans, size;
string str;
while (cin >> customers && customers)
{
cin >> str;
len = str.length();
v.clear();
ans = 0;
for (i = 0; i < len; i++)
{
size = v.size();
it = find(v.begin(), v.end(), str[i]);
if (customers > size && it == v.end())
v.push_back(str[i]);
else if (customers >= size && it != v.end())
v.erase(it);
else if (customers == size && it == v.end())
{
ans++;
continue;
}
else
ans++;
}
if (ans == 0)
cout << "All customers tanned successfully." << endl;
else
cout << ans/2 << " customer(s) walked away." << endl;
}
system("pause");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: