View Code of Problem 9

#include<cstdio>
#include<string>
#include<map>
#include<vector>
#include<iostream>
using namespace std;
int main(){
	int n,k=0;
	while(scanf("%d",&n)!=EOF){
		k++;
		int sum=0,cnt=0,flag=0;
		string str1,str2;
		vector<string> vt(n);
		map<string,int> mp;
		vt.clear();mp.clear();
		for(int i=0;i<n;i++){
			cin>>str1>>str2;
			vt[i]=str1;
			mp[vt[i]]++;
		}
		map<string,int>::iterator it=mp.begin();
		for(;it!=mp.end();it++){
			if(it->first=="Pleasant")	sum=sum+5*it->second;
			else if(it->first=="Pretty")	sum=sum+8*it->second;
			else if(it->first=="Athletic")	sum=sum+10*it->second,flag=1;
			else if(it->first=="Lazy")	sum=sum+15*it->second;
			else if(it->first=="Slow")	sum=sum+20*it->second;
			cnt+=it->second;
		}
		if(flag==1&&cnt>=10)	sum+=50;
		printf("Case #%d: %d\n",k,sum);
	}	
	return 0;
}

Double click to view unformatted code.


Back to problem 9