http://blog.csdn.net/ffq5050139/article/details/7832991

http://blog.watashi.ws/1944/the-8th-zjpcpc/

http://blog.csdn.net/crescent__moon/article/details/16801097

 #include<cstdio>
#include<cstring>
const int Max=;
double t[Max],p[Max],lev[Max];
double max(double a,double b){
return a>b?a:b;
}
int main(){
int i,j,n,T;
double sum,ans,anst,w;
scanf("%d",&T);
while(T--){
sum=ans=anst=;
scanf("%d",&n);
for(i=;i<n;i++)
scanf("%lf",&p[i]);
for(i=;i<n;i++)
scanf("%lf",&t[i]); lev[]=t[];
//printf("lev[1] = %.6lf\n",lev[0]);
for(i=;i<n;i++){
lev[i]=max(t[i]-t[i-],lev[i-]);
}
for(i=;i<n;i++){
w=lev[i];
sum=;
for(j=;j<n;j++){
if(w >= lev[j])
sum += p[j];
else
break;
} if(ans < sum / j){
ans=sum/j;
anst=w;
}
}
printf("%.6lf %.6lf\n",anst,ans);
}
return ;
}

Lazier Salesgirl


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling. She can sell the i-th customer a piece of bread for price pi. But she is so lazy that she will fall asleep if no customer comes to buy bread for more than w minutes. When she is sleeping, the customer coming to buy bread will leave immediately. It's known that she starts to sell bread now and the i-th customer come after ti minutes. What is the minimum possible value of w that maximizes the average value of the bread sold?

Input

There are multiple test cases. The first line of input is an integer T ≈ 200 indicating the number of test cases.

The first line of each test case contains an integer 1 ≤ n ≤ 1000 indicating the number of customers. The second line contains n integers 1 ≤ pi ≤ 10000. The third line contains n integers 1 ≤ ti ≤ 100000. The customers are given in the non-decreasing order of ti.

Output

For each test cases, output w and the corresponding average value of sold bread, with six decimal digits.

Sample Input

2
4
1 2 3 4
1 3 6 10
4
4 3 2 1
1 3 6 10

Sample Output

4.000000 2.500000
1.000000 4.000000

最新文章

  1. TPC-H
  2. [转]linux sort,uniq,cut,wc命令详解
  3. protobuf
  4. Daily Scrum 10.31
  5. H5版俄罗斯方块(2)---游戏的基本框架和实现
  6. Node.js之事件events
  7. GraphicsMagick为图片添加水印
  8. shell脚本实例-matrix
  9. RMAN - 备份异机恢复
  10. FPGA的图像处理技术,你知道多少?
  11. Ubuntu下使用ap-hotspot出现“Another process is already running&quot;问题的解决方案
  12. jQuery Animation实现CSS3动画
  13. DWR3.0框架入门(3) —— ScriptSession的维护及优化
  14. iReport默认参数和变量的含义解析【转】
  15. 手工搭建基于ABP的框架(3) - 登录,权限控制与日志
  16. react-router详细解释
  17. 安装vue-cli
  18. U3D Invoke系列函数
  19. SpringBoot配置属性之MVC
  20. OpenCV 学习笔记03 直线和圆检测

热门文章

  1. C# - String与StringBuilder
  2. 离线安装.NET 3.5小记
  3. C# Best Practices - Creating Good Methods
  4. Ubuntu 15.04 安装rmagick 2.15.4
  5. [Git]自译《Git版本控制管理》——1.介绍(二)_Git诞生
  6. Spring @Resource注解
  7. Android 开发笔记 “线程交互(Handler+Thread 和 AsyncTask)”
  8. [lua]笔试-按字典序列出指指定的序列的位置
  9. Qt学习 之 数据库(支持10种数据库)
  10. 异步和同步http请求超时机制