题目: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. VS2010 配置opencv环境

    大家在使用opencv的时候肯定会面对这样一个问题:根据官网以及大多数教程提供的方法中,似乎每一次新建一个opencv的新项目以后都需要重新再配置"VC++目录"中的"包 ...

  2. linux消息队列的使用

    消息队列 *消息队列是内核地址空间中的内部链表,通过内核在各个进程之间传递的内容.消息顺序发送到消息队列中,每个消息队列都有IPC标识符唯一地进行标识. msgbuf结构 struct msgbuf{ ...

  3. SQL Server性能常用语句

    查看各表的数据行数 SELECT o.name, i. ROWS FROM sysobjects o, sysindexes i WHERE o.id = i.id AND o.Xtype = ORD ...

  4. ORA-01031:insufficient privileges

    描述:oracle11g用scott用户在plsql上以sysdba身份登录显示以上错误,可是在cmd面板中却正常,网上各种找答案不没有对症,最后这位网友的回答解决了我的问题. 原帖网址:http:/ ...

  5. pku ppt some problem

    The Triangle  http://poj.org/problem?id=1163 暴力dfs的话,每个节点有两条路可以走,那么n个节点复杂度就是2^n  n=100  超时   dp来做 就优 ...

  6. 获取c++ edit控件内容

    CString str1,str2; ((CEdit*)GetDlgItem(IDC_EDIT1))->GetWindowText(str1); ((CEdit*)GetDlgItem(IDC_ ...

  7. 1. what is Lua?

    glue language Lua is a proven, robust language, small.

  8. Android开发--使用真机进行USB调试程序

    在android小程序的开发过程中,使用eclipse中的虚拟机进行程序开发速度较慢,用真机开发可以显著提高调试的速度. 这里我用的操作系统是win7专业版,手机型号HM1S: 进行USB调试的主要步 ...

  9. hdu 3441 Rotation

    总的来说,这题要2次用到polya定理. 由题目条件A*A=B*B+1,变形为(A-1)*(A+1)=K*B*B; 分别分解A-1和A+1的质因数,在合并在一起. 第一步:搜索B,对B*B的正方形涂色 ...

  10. Android 监测手机联网状态 wifi、移动数据流量、无联网状态

    手机当完成联网时会发送一个广播,我们只要创建一个广播接收者即可,代码如下: package com.example.NetworkChangeReceiver2; import android.con ...