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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七刀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值