HDU4147 KFC -Z+W

#include<stdio.h>                              
#include<string.h>                             
int main()                                     
{                                              
 int n,B,D,f,F,i,l,j,a[10010],min,b,c,d;         
 char s[10010];                                
                                               
 while(~scanf("%d%d%d%d%d",&n,&B,&D,&f,&F))    
 {                                             
                                    
  b=B+D+f;                                     
  c=B*2+D*2+F;                                 
  d=B*3+D*3+F*2;                               
       	                                       
  for(i=1;i<=n;i++)                            
  {                                            
   scanf("%s",s);                              
   l=strlen(s);                                
   a[i]=0;                                     
                                               
   for(j=0;j<l;j++)                            
   {                                           
   	if(s[j]=='A')a[i]=a[i]+b;                  
   	else if(s[j]=='B')a[i]=a[i]+c;             
   	else if(s[j]=='C')a[i]=a[i]+d;             
   }                                           
                                               
  }                                            
  min=a[1];                                    
  for(i=2;i<=n;i++)                            
   if(a[i]<min)min=a[i];                       
  printf("%d\n",min);                          
                                                                                                                                                                                            
 }                                             
                                               
 return 0;                                     
}                                              

KFC -Z+W

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1472 Accepted Submission(s): 707


Problem Description
Welcome to KFC!
We love KFC, but we hate the looooooooooong queue.
Z is a programmer; he’s got an idea on the queue time computing.
Z chooses the shortest queue at first time.
He wrote a j2me program to predicate the time he have to wait in the queue. Now, he comes to KFC to test his program.
BUT, he ignored some important things to get the precise time.
* People choose different foods
* Time used on foods various
W encountered him just while his wondering on the problem, so he discussed it with HER.
W suggested that they can add variables to this
* A type ,who is looking down on the cell phone novel should come here alone, will call for 1 hamburger, 1 drink and 1 small fries
* B type, two talkative lovers, 1 hamburger and 1 drink for each one and another big fires
* C type, middle aged father/mother looks, brings their child out. 3 hamburgers, 3 drinks and two big friezes.
Generally represent the types usually appear, not the exactly math work.
They reprogram the app on W’s HTC-G1 with bash, run it and go for the fastest queue.

Input
Input contains multiple test cases, and for each case:
First line: n B D f F, stands for n queues, time for hamburger B, time for Drink D, time for small fries f, time for big Fries F.
The next n lines: the types of each line using ABC characters.
(1<n,B,D,f,F<=100)

Output
For each case, please output the least time to wait in one line.

Sample Input
  
  
3 2 2 1 2 ABCCBACBCBAB CBCBABBCBA ABC

Sample Output
  
  
31

Author
zhblue@ZJICM

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值