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 ...
随机推荐
- Jquery 固定悬浮层以及固定表头
/* =========================================================== * jquery.autofix_anything.js v1 * === ...
- C#截取文件的文件夹地址
创建文件 if (!File.Exists(file_name)) { File.Create(file_name).Close(); } using System.IO; 如果没有.Close(), ...
- shell 学习基地
http://blog.csdn.net/column/details/shell-daily-study.html?&page=2
- 如何在Eclipse中配置Tomcat服务器
之前使用MyEclipse来开发Web应用,可以在MyEclipse中配置服务器,配置完后,直接运行服务器即可,很方便. 最近切换到Eclipse开发环境,发现使用Tomcat的方式不太一样,因此在此 ...
- Linux 命令整理 —— 用户管理
Linux用户管理以读.写.执行动作为权限,以用户组为单位,限制用户行为.对于文件的的操作,可以限制读.写.执行中的哪一种,也可以限制文件所有者.组用户.组外用户相应的权限. 所以,要建立用户,最好先 ...
- C# 虚方法 与 隐藏方法(new) 区别
重写和隐藏的定义: 重写:继承时发生,在子类中重新定义父类中的方法,子类中的方法和父类的方法是一样的 例如:基类方法声明为virtual(虚方法),派生类中使用override申明此 ...
- make -f dc_debug.mak 提示错误"/usr/bin/ld:can not find -l***"解决办法
在公司不同服务器上"make -f ***"程序的时候,有的服务器可以编译通过,有的却提示"/usr/bin/ld:can not find -l***"的错误 ...
- uva 757
贪心 优先队列 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> ...
- linux网卡速率和双工模式的配置
linux网卡速率和双工模式的配置 (2012-09-06 14:39:57) 转载▼ 标签: 科技 网络接口 协商 网卡 工具 it 分类: Linux 改变网络接口的速度和协商方式的工具miito ...
- lintcode :Remove Duplicates from Sorted Array II 删除排序数组中的重复数字 II
题目: 删除排序数组中的重复数字 II 跟进“删除重复数字”: 如果可以允许出现两次重复将如何处理? 样例 给出数组A =[1,1,1,2,2,3],你的函数应该返回长度5,此时A=[1,1,2,2, ...