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 ... 
随机推荐
- Web UI Design Patterns 2014
			http://www.uxpin.com/web-design-patterns.html?utm_source=Interaction%20Design%20Best%20Practices%20V ... 
- 开发中/listfile.jsp(11,31) quote symbol expected 这个错误
			可能是因为11行33列,少了一个引号. 
- 在云服务器搭建WordPress博客(二)使用xampp并解决端口冲突问题
			要搭建一台外界可以访问的服务器,就必须有对应的服务器环境.在这里我用的xampp集成环境(我是菜鸟级......),xampp集成了PHP+Apache+MySQL+perl,安装方便,不用再特意去设 ... 
- nginx 如何显示真实ip
			nginx做反向代理显示在后台访问的真实ip总是显示127.0.0.1 只要添加如下内容: proxy_set_header Host $host; proxy_set_header X-For ... 
- HDU 3974 Assign the task 暴力/线段树
			题目链接: 题目 Assign the task Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ... 
- 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空)
			// test20.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include< ... 
- 汇编中Enter与Leave指令
			Enter的作用相当==push ebp和mov ebp,esp 这后面两句大家很熟悉吧?函数开始一般都是这两句 Leave的作用相当==mov esp,ebp和pop ebp 而这后面这两句也很常见 ... 
- Application.persistentDataPath 的一个小坑
			打包之前在Android的Player Setting里面选择WriteAccess (写入访问) Internal Only:表示Application.persistentDataPath的路径是 ... 
- android2.3 -添加自定义按键:作唤醒功能 .
			最近需要做个唤醒功能,当按键的时候android系统唤醒并点亮屏,在长按键中,系统不能在进入睡眠. 驱动方面: 1:在平台设备文件中添加 一个按键,定义为唤醒源! \arch\arm\mach-s5p ... 
- What are Scopes?
			scope is an object that refers to the application model. It is an execution context for expressions. ... 
