编程介的小学生 2017-11-18 03:32 采纳率: 20.5%
浏览 931
已结题

KFC -Z+W

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

  • 写回答

1条回答 默认 最新

  • qq_41509918 2018-07-26 11:27
    关注

    题上意思是说,会先输入五个数,分别是一共有n个队伍,一个汉堡所花的时间,一杯饮料所花的时间,小份油炸食品的时间f,大份油炸的时间F
    然后会输入n行只包含ABC三个字母的字符串,A类顾客需要一个汉堡,一杯饮料和一个小份油炸食品,B类顾客需要一个汉堡,一杯饮料和一个大
    份的油炸食品,C类顾客需要三个汉堡,三杯饮料喝两份大份汉堡。要求输出哪一个队列所花的时间最少。
    PS:样例输出应该是3,并没有第31支队伍啊!
    以下是C++代码,
    #include
    #include
    #include
    #define INF 0x3f3f3f3f
    using namespace std;
    int guest[3];//记录每类顾客所花的总时间
    int main() {
    int n;//队列数
    int b,d,f,F;//各种食品所花的时间
    scanf("%d%d%d%d%d",&n,&b,&d,&f,&F);
    guest[0] = b + d + f;//一个A类顾客所花时间
    guest[1] = b + d + F;//一个B类顾客所花时间
    guest[2] = 3*b + 3*d + 2*f;//一个C类顾客所花时间
    int mins = INF;//记录比较之前输入的耗时最少的队伍所花的时间,初始化为无穷大
    int ans = 0;//记录之前输入的耗时最少的队伍是第几只队伍
    for( int i = 1; i <= n; i++ ){
    string s;
    cin >> s;
    int sum = 0;
    for( int j = 0; j < s.length(); j++ )
    sum += guest[ s[i] - 'A' ]; // 计算这一个队伍所花的总时间,存在sum中
    if( sum < mins ){//比较当前队伍与之前耗时最短的队伍的耗时,如果本支队伍耗时更短则更新最少耗时队伍的耗时与编号
    mins = sum;
    ans = i;
    }
    }
    printf("%d\n",ans);
    return 0;
    }

    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的