1. 这个题比上个题简单得多,也是超过W时间会睡着,睡着就再也不会卖了,
    顾客按时间顺序来的,但是可能有顾客同时到(同时到如果醒着就全卖了),
    并且每个人只买一块面包,也是求最大的W,使得卖出面包的平均价格最高。
  2. 同理最大的W一定是某两个相邻人的时间差。因为睡着了就不会醒了,
    所以枚举的时间差必须越来越大。如果某个时间差比前面枚举过的小也没啥意义
    (因为在前面就会睡着)。因此,直接枚举第i个人和第(i-1)个人的那个时间差
    (在此之前的时间差都比这个小),然后从第(i+1)个人开始连续一段人的时间差都不超过这个值,
    直到第j个人的时间差比这个大,则从第一个人到第j个人都没睡着卖出去了,算一个均值。
    再从第j个人的时间差开始判断,相当于扫了一遍。时间复杂度O(n)。
  3.  
  4. 类似这样:
  5. for (i=1;i<=n;i=j) {
  6. for (d=t[i]-t[i-1],j=i;t[j]-t[j-1]<=d;++j) { 累加和不清0}
  7. }

  

  1. //#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
  2. #include <stdio.h>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <cstring>
  6. #include <cmath>
  7. #include <stack>
  8. #include <string>
  9. #include <map>
  10. #include <set>
  11. #include <list>
  12. #include <queue>
  13. #include <vector>
  14. #include <algorithm>
  15. #define Max(a,b) (((a) > (b)) ? (a) : (b))
  16. #define Min(a,b) (((a) < (b)) ? (a) : (b))
  17. #define Abs(x) (((x) > 0) ? (x) : (-(x)))
  18. #define MOD 1000000007
  19. #define pi acos(-1.0)
  20.  
  21. using namespace std;
  22.  
  23. typedef long long ll ;
  24. typedef unsigned long long ull ;
  25. typedef unsigned int uint ;
  26. typedef unsigned char uchar ;
  27.  
  28. template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
  29. template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;}
  30.  
  31. const double eps = 1e- ;
  32. const int N = ;
  33. const int M = * ;
  34. const ll P = 10000000097ll ;
  35. const int MAXN = ;
  36. const int INF = 0x3f3f3f3f ;
  37.  
  38. int n;
  39. double t[], p[], lev[];
  40. double sum, ans, anst, w;
  41.  
  42. int main() {
  43. std::ios::sync_with_stdio(false);
  44. int i, j, T, k, u, v, numCase = ;
  45. cin >> T;
  46. while (T--){
  47. sum = ans = anst = ;
  48. cin >> n;
  49. for (i = ; i < n; ++i) cin >> p[i];
  50. for (i = ; i < n; ++i) cin >> t[i];
  51. lev[] = t[];
  52. for (i = ; i < n; ++i){
  53. lev[i] = Max(t[i] - t[i - ], lev[i - ]);//找到相邻两人间的时间差
  54. }
  55. for (i = ; i < n; ++i){
  56. w = lev[i];
  57. sum = ;
  58. for (j = ; j < n; ++j){
  59. if (w >= lev[j]){
  60. sum += p[j];
  61. }
  62. else break;
  63. }
  64. if (ans < sum / j){
  65. ans = sum / j;
  66. anst = w;
  67. } else if (ans == sum / j && anst > w){
  68. anst = w;
  69. }
  70. }
  71. printf("%.6f %.6f\n", anst, ans);
  72. }
  73.  
  74. return ;
  75. }

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

  1. ZOJ 3607 Lazier Salesgirl (枚举)

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

  2. ZOJ 3607 Lazier Salesgirl(贪心)

    题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3607 题意:一个卖面包的小姑娘,给第i个来买面包的人的价格是pi, ...

  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. OutputDebugString 输出信息到调试器

    #include <Windows.h>#include <stdio.h>#include <stdarg.h> void __cdecl odprintf(co ...

  2. oracle10g安装图解(win7)

    一.Oracle10g 安装预备步骤取得 Oracle 10g 安装程序,或从 Oracle 技术网(OTN)下载光盘映像.在评估阶段您可以免费下载和使用无技术限制的全功能 Oracle,但在正式的商 ...

  3. Node Node

    http://www.nodejs.org/ http://outofmemory.cn/code-snippet/1403/node-javascript-classic-introduction- ...

  4. spring boot 下 500 404 错误页面处理

    spring boot 作为微服务的便捷框架,在错误页面处理上也有一些新的处理,不同于之前的spring mvc 500的页面处理是比较简单的,用java config或者xml的形式,定义如下的be ...

  5. poj 2051 Argus(优先队列)

    题目链接: http://poj.org/problem?id=2051 思路分析: 优先级问题,使用优先队列求解:当执行某个任务后,再增加一个任务到队列中, 该任务的优先级为执行任务的时间加上其时间 ...

  6. Cloud Foundry warden container 安全性探讨

    本文将从Cloud Foundry中warden container的几个方面探讨warden container的安全性. 1. warden container互訪 1.1.  互訪原理· 在Cl ...

  7. C#中静态方法的运用和字符串的常用方法(seventh day)

    又来到了今天的总结时间,由于昨天在云和学院学的知识没有弄懂,今天老师又专门给我们非常详细地讲了一遍,在这里非常谢谢老师.O(∩_∩)O 话不多说,下面就开始为大家总结一下静态方法的运用和字符串的常用方 ...

  8. win7如何快速设置开机启动项?

    添加开机启动项方法: 找到windows开始菜单->所有程序->启动,右键打开, 进入C:\Users\Ocean\AppData\Roaming\Microsoft\Windows\St ...

  9. Arrays类学习笔记

    Arrays.asList(arr); 该方法可以把数组变成List集合. String[] arr = {"abc","cc"}; List<Strin ...

  10. JBPM6工作台使用Mysql数据库

    前面已经安装好jbpm了.现在进行数据库的替换.很简单: 1,修改 build.properties 原: # default is H2 H2.version=1.3.168 db.name=h2 ...