• The mell hall——坑爹


    The mell hall

    题目描述

    In HUST,there are always manystudents go to the mell hall at the same time as soon as the bell rings.

    Students have to queue up for a meal,and the queue is awalys long,So it takes much time.Suposse there

    are N people in a queue,each personhas two characteristic value A and B(both of them are integers,read

    input for more details),the i-thperson in the queue have to spend m(i) =

    A1A2

    :::Ai 1

    Bi

    minutes,Where

    Ai

    ,Bi

    is the i-th person.s valueA,B.Notice that if the order of the queue changes,the waiting time one

    spend(that is,the value of m(i))maychanges too. Of course,every student want to reduce the time he

    spend.

    Apparently,it is impossible to makeeveryone satis
    ed,in this problem,we only need to minimize the

    waiting time of one who spend thelongest time in the queue,that is,minimize Max m(1),m(2),,,m(n).You

    can change the order of the queue inanyway in order to complete this problem.

    You are asked to output the originallocation in the queue of the person who will cost the longest time

    under optimal solution. Uniquity isinsured by the given data.

    输入

    There are multiple test cases.

    For each case, the
    rst line contains one integerN(1N1000).

    The second line containsNintegers Ai

    .(0 < Ai <100000)

    The third line containsNintergers Bi

    (0< Bi <10).

    (Bi <10< Ai*bi)

    输出

    You are asked to output the originallocation in the queue of the person who will cost the longest time

    under optimal solution. Uniquity isinsured by the given data.

    样例输入

    3

    15 20 25

    1 3 2

    样例输出

    2

    意思没看懂,听人解释后很简单。就是找出a[i]*b[i]的最大值的i值就行了!

    #include<iostream>
    using namespace std;
    int main()
    {
    int n,i;
    int a[100005],b[100005];
    int m,t;
    while(cin>>n)
    {
    for(i=0;i<n;i++)
    cin>>a[i];
            for(i=0;i<n;i++)
    cin>>b[i];
    m=a[0]*b[0];
    t=0;
    for(i=1;i<n;i++)
    {
    if(a[i]*b[i]>m)
    {
    m=a[i]*b[i];
    t=i;
    }
    }
    cout<<t+1<<endl;
    }
    return 0;
    }

  • 相关阅读:
    More Effective C++: 02操作符
    More Effective C++: 01基础议题
    GCD学习(七) dispatch_apply
    GCD学习(六) dispatch_async 和dispatch_sync
    GCD学习(五) dispatch_barrier_async
    GCD 学习(四) dispatch_group
    关于 block的一些浅识
    异常日志记录 DDLog
    Effective Objective-C [下]
    Effective Objective-C [上]
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3180225.html
Copyright © 2020-2023  润新知