CodeForces 503A Bar

H - Bar
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Appoint description: 

Description

According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check any person, i.e. learn his age and the drink he is having at the same time. What minimal number of people should Vasya check additionally to make sure that there are no clients under 18 having alcohol drinks?

The list of all alcohol drinks in Berland is: ABSINTHBEERBRANDYCHAMPAGNEGINRUMSAKETEQUILAVODKA,WHISKEYWINE

Input

The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does not contain spaces and other unnecessary separators.

Only the drinks from the list given above should be considered alcohol.

Output

Print a single number which is the number of people Vasya should check to guarantee the law enforcement.

Sample Input

Input
5
18
VODKA
COKE
19
17
Output
2

Hint

In the sample test the second and fifth clients should be checked.

题意:判断不满18岁并且喝酒的有多少人,题上有两种输入,一种是确定喝的是酒,给出了该人年龄,一种是确定为不满18岁,给出了喝的饮料的名字。

思路:直接看代码吧

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	char s[][110]={"ABSINTH","BEER","BRANDY","CHAMPAGNE","GIN","RUM","SAKE","TEQUILA","VODKA","WHISKEY","WINE"};
	int t,n,i,j;
	char str[110];
	while(scanf("%d",&n)!=EOF)
	{
		int count=0;
		for(i=0;i<n;i++)
		{
			scanf("%s",str);
			int len=strlen(str);
			if(len==1&&str[0]-'0'>=0&&str[0]-'0'<=9)
			{
				count++;
				continue;
			}
			if(len==2&&str[0]-'0'==1&&(str[1]-'0'>=0&&str[1]-'0'<8))
			{
				count++;
				continue;
			}
			for(j=0;j<11;j++)
			{
				if(strcmp(str,s[j])==0)
				{
					count++;
					break;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值