【有点坑】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;
}
#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;
}
相关文章推荐
- ZOJ 3607 Lazier Salesgirl 贪心
- ZOJ 3607 Lazier Salesgirl (贪心)
- ZOJ 3607-Lazier Salesgirl-贪心
- ZOJ Problem Set - 3607 Lazier Salesgirl
- ZOJ-3607-Lazier Salesgirl【模拟】【贪心】【9th浙江省赛】
- ZOJ _3607_Lazier Salesgirl(贪心)
- zoj 3607 Lazier Salesgirl 暴力 前缀和
- ZOJ 3607 Lazier Salesgirl (贪心,模拟)
- ZOJ 3607 Lazier Salesgirl (贪心)
- zoj 3607 Lazier Salesgirl
- ZOJ 3607 Lazier Salesgirl【贪心】
- ZOJ 3607 Lazier Salesgirl(贪心啊 )
- 【 ZOJ 3607】Lazier Salesgirl
- ZOJ 3607 Lazier Salesgirl 贪心
- zoj 3607 Lazier Salesgirl 贪心
- ZOJ 3607 Lazier Salesgirl
- ZOJ 3607 Lazier Salesgirl
- ZOJ 3607 Lazier Salesgirl
- zoj 3607 Lazier Salesgirl
- ZOJ - 3607 Lazier Salesgirl(模拟)