View Code of Problem 9

#include<bits/stdc++.h>
using namespace std;
map <string,int> mp;
void init() {
	mp["Pleasant goat"] = 5;
	mp["Pretty goat"] = 8;
	mp["Athletic goat"] = 10;
	mp["Lazy goat"] = 15;
	mp["Slow goat"] = 20;
}
int main()
{
	string s1="Athletic goat";
	int flag;
	int sum,n,k;
	string str,str1,goat;
	k=0;
	init();
	while(cin>>n) {
		k++;
		sum=0;
		flag=0;
		for(int i=0;i<n;i++){
//			getline(cin,goat);
			cin>>str1>>goat;
			str=str1+" "+goat;
			if(str==s1) flag=1;
			sum+=mp[str];
		}
		if(n>=10&&flag)
			sum+=50;
		cout<<"Case #"<<k<<": "<<sum<<endl;	
	}
	
	return 0;
 } 

Double click to view unformatted code.


Back to problem 9