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;
}
最新文章
- [LeetCode] Flip Game 翻转游戏
- django authenticate
- shell获取ip
- UVa 1594 (Floyd判圈) Ducci Sequence
- iPhone 各版本屏幕分辨率
- android学习—should use @string resource警告
- 一步一步学android之布局管理器——RelativeLayout
- [编程语言][java][java se]java泛型中? T K V E含义(学习)
- Boost::Thread 多线程的基础知识
- hdu1054(最小顶点覆盖)
- Windows Phone 的控件倾斜效果
- Ubuntu下修改DNS重启也能用的方法
- js 各进制前缀 及 转换
- c++11 强类型枚举 enum class
- windows server 2016 安装iis
- 求去掉一条边使最小割变小 HAOI2017 新型城市化
- file相关方法
- 个人理解的int数组和char数组
- ubuntu源列表(清华,阿里,官方,选一即可)
- 为django平台生成模拟用户,建立用户组,并将用户加入组
热门文章
- 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: SSL Provider, error: 0 - 接收到的消息异常,或格式不正确。)
- OSGi:生命周期层
- OWAP Top 10
- VC GDI双缓冲机制绘图防屏幕闪烁实现步骤
- MySQL内存表(MEMORY)说明 | 一个PHP程序员的备忘录
- 设计模式(三)-- 适配器模式(Adapter)
- 原型链(__proto__)
- jquery clone方法
- css中的hover ,关于li与a标签的问题
- Java泛型之<;T>;