题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3607

题意:一个卖面包的小姑娘,给第i个来买面包的人的价格是pi, 每个人的时间是ti,

问用最小的时间间隔 求最大的平均值。

刚开始没有 考虑,后一个的时间间隔要大于之前的最大的时间间隔 才行。。。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = +;
const int INF = <<;
int p[maxn], t[maxn]; int main()
{
int i, j, T, n;
double sum, ty, tty;
double Maxaver, x, Mint;
while(~scanf("%d", &T))
{
while(T--)
{
Maxaver = -INF;
tty = -INF;
Mint = INF;
sum = ;
scanf("%d", &n);
for(i = ; i <= n; i++)
scanf("%d", &p[i]);
for(j = ; j <= n; j++)
scanf("%d", &t[j]); t[n+] = INF; //初始一个最大值
for(i = ; i <= n; i++)
{
ty = t[i] - t[i-];
if(ty > tty)
tty = ty;
sum+=p[i];
x = sum*1.0/i*1.0;
if(x > Maxaver && t[i+]-t[i]>tty)
{
Mint = tty;
Maxaver = x;
}
}
printf("%.6lf %.6lf\n", Mint, Maxaver);
}
}
return ;
}

ZOJ 3607 Lazier Salesgirl(贪心)的更多相关文章

  1. ZOJ 3607 Lazier Salesgirl 贪心

    这个题比上个题简单得多,也是超过W时间会睡着,睡着就再也不会卖了,顾客按时间顺序来的,但是可能有顾客同时到(同时到如果醒着就全卖了),并且每个人只买一块面包,也是求最大的W,使得卖出面包的平均价格最高 ...

  2. ZOJ 3607 Lazier Salesgirl (枚举)

    Lazier Salesgirl Time Limit: 2 Seconds Memory Limit: 65536 KB Kochiya Sanae is a lazy girl who makes ...

  3. ZOJ 3607 Lazier Salesgirl

    Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling ...

  4. zjuoj 3607 Lazier Salesgirl

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3607 Lazier Salesgirl Time Limit: 2 Sec ...

  5. ZOJ 3607贪心算法

    http://blog.csdn.net/ffq5050139/article/details/7832991 http://blog.watashi.ws/1944/the-8th-zjpcpc/ ...

  6. H - Lazier Salesgirl

    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practic ...

  7. ZOJ 3606 Lazy Salesgirl 浙江省第九届省赛

    Lazy Salesgirl Time Limit: 5 Seconds      Memory Limit: 65536 KB Kochiya Sanae is a lazy girl who ma ...

  8. POJ 1862 &amp; ZOJ 1543 Stripies(贪心 | 优先队列)

    题目链接: PKU:http://poj.org/problem?id=1862 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...

  9. 2017CCPC秦皇岛G ZOJ 3987Numbers(大数+贪心)

    Numbers Time Limit: 2 Seconds      Memory Limit: 65536 KB DreamGrid has a nonnegative integer n . He ...

随机推荐

  1. IP地址格式控制

    /// <summary> /// 验证IP格式是否输入正确 /// </summary> /// <param name="ip"></ ...

  2. find查找指定类型文件并删除

            问题描述:                      查找当前目录下指定类型的文件              问题解决:                     (1)find命令   ...

  3. Matlab中mat2cell的使用

    怎样用mat2cell将一个100*100的矩阵分成10个10*100的矩阵? 根据帮助中 c = mat2cell(x,m,n)应该这样写 mat2cell(x,[10 10 10 10 10 10 ...

  4. Eclipse下PHP开发 插件安装

    PHPeclipse是什么? PHPeclipse是Eclipse的一个插件,它为php开发人员提供了一个集成的开发环境.Eclipse官方下载地址:http://www.eclipse.org/ P ...

  5. Relearning PHP (2) – php 的浮点数float

    Relearning PHP (2) – php 的浮点数float 暂无评论 php有很多坑,但是并不妨碍他是最好的语言.其他语言对于浮点数处理同样有问题,这应该是个“共有坑”.不信可以用googl ...

  6. .net RESX资源文件

    RESX资源文件最大的优势就是: 支持多语言 快速创建资源 管理方便 RESX可以支持多语言,Visual Studio编译后会出现附属程序集(satellite assembly),事实上是连接器( ...

  7. switch_to 理解

    最近看linux0.11源码时,看到任务切换函数switch_to,感觉很晦涩,于是在网上查了一些资料,现在终于有些眉目,特记录于此,以方便大家参考,有什么错误或不足之处,还请大家指出~ switch ...

  8. Calling Lua From a C Program

    Introduction From a running C program, you can call a Lua script. The C program can pass arguments t ...

  9. What is the difference between Views and Materialized Views in Oracle?

    aterialized views are disk based and update periodically base upon the query definition. Views are v ...

  10. C#和Javascript中 正则表达式使用的总结

    说明:本文并非原创,而是从网站上搜集了一些资料整理的!如有雷同,纯属巧合 1.js中正则表达式的使用 在js中定义正则表达式很简单,有两种方式,一种是通过构造函数,一种是通过//,也就是两个斜杠.例如 ...