Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
too watery#include <iostream> #include <string> using namespace std; int main() { while(1){ int bed; cin >> bed; if(bed == 0) return 0; string s; cin >> s; int len = s.length(); bool used[30] = {0}; int usedNo = 0; int gunNo = 0; for(int i = 0; i < len; i++){ char c = s[i]; if(used[c-'A']){ used[c-'A'] = 0; usedNo--; } else{ used[c-'A'] = 1; usedNo++; if(usedNo > bed) gunNo++; } } if(gunNo == 0) cout << "All customers tanned successfully." << endl; else cout << gunNo << " customer(s) walked away." << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator