ZOJ 3607 Lazier Salesgirl(贪心)
题目: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(贪心)的更多相关文章
- ZOJ 3607 Lazier Salesgirl 贪心
这个题比上个题简单得多,也是超过W时间会睡着,睡着就再也不会卖了,顾客按时间顺序来的,但是可能有顾客同时到(同时到如果醒着就全卖了),并且每个人只买一块面包,也是求最大的W,使得卖出面包的平均价格最高 ...
- ZOJ 3607 Lazier Salesgirl (枚举)
Lazier Salesgirl Time Limit: 2 Seconds Memory Limit: 65536 KB Kochiya Sanae is a lazy girl who makes ...
- ZOJ 3607 Lazier Salesgirl
Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling ...
- zjuoj 3607 Lazier Salesgirl
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3607 Lazier Salesgirl Time Limit: 2 Sec ...
- ZOJ 3607贪心算法
http://blog.csdn.net/ffq5050139/article/details/7832991 http://blog.watashi.ws/1944/the-8th-zjpcpc/ ...
- H - Lazier Salesgirl
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Status Practic ...
- ZOJ 3606 Lazy Salesgirl 浙江省第九届省赛
Lazy Salesgirl Time Limit: 5 Seconds Memory Limit: 65536 KB Kochiya Sanae is a lazy girl who ma ...
- POJ 1862 & ZOJ 1543 Stripies(贪心 | 优先队列)
题目链接: PKU:http://poj.org/problem?id=1862 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...
- 2017CCPC秦皇岛G ZOJ 3987Numbers(大数+贪心)
Numbers Time Limit: 2 Seconds Memory Limit: 65536 KB DreamGrid has a nonnegative integer n . He ...
随机推荐
- ./configure --prefix=
一直用这个选项prefix=,但不知道,啥意思. 转载自:----------------------------------------------------------------------- ...
- ios 多任务学习笔记
一.检测多任务是否支持: - (BOOL) isMultitaskingSupported{ BOOL result = NO; if ([[UIDevice currentDevice] respo ...
- SVN提交错误:working copy is not up-to-date解决方法
我在项目中删了2个jar,然后SVN提交,一直提交不成功 svn在提交时报错如下图: working copy is not up-to-date svn:commit failed(details ...
- Vim Cscope安装与使用
问题描述: Cscope是VIM适用的工具和插件,通过Cscope可以方便的获取某个函数的定义以及被那些函数调用 问题解决: (1)Cscope安装 注: ...
- 首次push本地代码到github上出现的问题及解决方案
刚创建的github版本库,在push代码时出错: $ git push -u origin masterTo git@github.com:******/Demo.git ! [rejected] ...
- 关于vs2010 起始页
vs2010 起始页不显示怎么解决 工具 ---> 选项---->环境---->启动---->启动时(选项框),然后点击框尾的下拉三角按钮,点选"显示起始页" ...
- WPF Loader
xaml <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml ...
- Mac OS X中MacPorts的安装使用备忘
Mac下面除了用dmg.pkg来安装软件外,比较方便的还有用MacPorts来帮助你安装其他应用程序,跟BSD中的ports道理一样.MacPorts就像apt-get.yum一样,可以快速安装些软件 ...
- oracle 字符集
---- 在国内外大中型数据库管理系统中,把ORACLE作为数据库管理平台的用户比较多.ORACLE 不论是数据库管理能力还是安全性都是无可非议的,但是,它在汉字信息的显示方面着实给中国用户带来不少麻 ...
- Android SDK下载地址
原地址:http://lameck.blog.163.com/blog/static/38811374201262111309677/ Android SDK.ADT.tools等官方下载地址(201 ...