您的位置:首页 > 其它

【有点坑】ZOJ 3607 Lazier Salesgirl

2014-04-04 19:06 357 查看
#include <stdio.h>
#include <map>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <iostream>
#define mm(a) memset(a, 0, sizeof(a))
using namespace std;

int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n;
scanf("%d", &n);
double p[1050];
for(int i = 1; i <= n; i++)
scanf("%lf", &p[i]);
double time[1050];
time[0] = 0;
for(int i = 1; i <= n; i++)
scanf("%lf", &time[i]);
time[n + 1] = 0x3f3f3f3f;
double maxtime = 0, hehe = 0;
double sum = 0, maxx = 0;
for(int i = 1; i <= n; i++)
{
sum += p[i];
hehe = max(hehe, time[i] - time[i - 1]);
if( hehe < time[i+1] - time[i] && sum > maxx * i ) //只有hehe小于后面的时间的时候,才更新平均值
{
maxtime = hehe;
maxx = sum / i;
}
}
printf("%.6lf %.6lf\n", maxtime, maxx);
}
return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: