Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

too watery

Posted by KatrineYang at 2016-09-01 22:08:51 on Problem 1250
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator