http://codeforces.com/gym/101257/problem/GGym 101257G

题意:给出n个人,和一个数s,接下来给出每个人当前的分数和输掉的概率。当一个人输了之后就会掉s分。求第i个人当前的分数大于第j个人当前的分数并且比赛结束后第i个人的分数小于第j个人的(i,j)对数的期望。

思路:用尺取的做法,r指针在前面,l指针在后面,从后往前扫,记录一个前缀和lose,代表前面r指针遇到的人输的概率,当扫到valr - s >= vall的时候停止r,让l往左扫,期间lose要减掉遇到的人输的概率,因为相同权值的人不会对彼此有贡献,当扫到和原本的权值不同的数停止,加上贡献,贡献为lose*win[l]。但是比赛的时候加了一个离散化,把所有相同权值的点放在一起考虑了,不知道是什么原因错了。重新直接做就A了。想法挺容易,但是有些细节上的东西还是需要仔细把握。

 #include <bits/stdc++.h>
using namespace std;
#define N 200010
int w[N];
double e[N];
int main() {
int n, s;
scanf("%d%d", &n, &s);
for(int i = ; i <= n; i++) scanf("%d", &w[i]);
for(int i = ; i <= n; i++) scanf("%lf", &e[i]);
double now = , ans = ;
int l = n, r = n, sameindex = n;
while(l) {
while(w[r] - s < w[l] && r) now += e[r--];
while(w[l] == w[sameindex] && sameindex) now -= e[sameindex--];
while(l > sameindex) ans += (1.0 - e[l--]) * now;
}
printf("%.9f\n", ans);
return ;
}

Gym 101257G:24(尺取)的更多相关文章

  1. Gym 101257G 24 (概率+二分)

    题意: 有一道分值为sa的题,n个人比赛写这道题,按照递减的顺序给出每个人的当前分数,和每个人写不出这道题的概率,让你输出有反超现象出现的期望 思路:由于之前把题目翻译错了导致很久没有相通,后来看了别 ...

  2. Gym 100703I---Endeavor for perfection(尺取)

    题目链接 http://codeforces.com/problemset/gymProblem/100703/I Description standard input/outputStatement ...

  3. poj2100还是尺取

    King George has recently decided that he would like to have a new design for the royal graveyard. Th ...

  4. Sum of Consecutive Prime Numbers(素数打表+尺取)

    Description Some positive integers can be represented by a sum of one or more consecutive prime numb ...

  5. POJ:2100-Graveyard Design(尺取)

    Graveyard Design Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 8504 Accepted: 2126 Cas ...

  6. NOJ 1072 The longest same color grid(尺取)

    Problem 1072: The longest same color grid Time Limits:  1000 MS   Memory Limits:  65536 KB 64-bit in ...

  7. hdu 4123 Bob’s Race 树的直径+rmq+尺取

    Bob’s Race Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Probl ...

  8. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) E. Cubes (尺取)

    题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序 ...

  9. poj2566尺取变形

    Signals of most probably extra-terrestrial origin have been received and digitalized by The Aeronaut ...

随机推荐

  1. JDK源码阅读—ArrayList的实现

    1 继承结构图 ArrayList继承AbstractList,实现了List接口 2 构造函数 transient Object[] elementData; // 数组保存元素 private i ...

  2. SICP 1.11-1.13

    1.11 递归版本 (define (f n) (cond ((< n ) n) ()) (* (f (- n )) ) (* (f (- n )) ))))) 迭代版本 (define (f ...

  3. Gralde 网络代理

    Gralde 网络代理 Gradle在编译项目的时候,需要下载一些依赖.墙外的网络就需要设置代理了. 设置的方法,见文档: Accessing the web through a HTTP proxy ...

  4. UWP应用载入SVG图片的兼容性方案

    原文 UWP应用载入SVG图片的兼容性方案 新版本<纸书科学计算器>的更新点之一,就是优化了表达式的显示方式.在旧版本中,表达式里的符号是用png图片显示的,当用户放大看的时候会发现一些锯 ...

  5. 提示Windows Phone IP over USB Transport (IpOverUsbSvc)未运行,如何解决

    原文:提示Windows Phone IP over USB Transport (IpOverUsbSvc)未运行,如何解决 uwp项目在安装测试时提示,"引导"Device&q ...

  6. API HOOK介绍 【转】

    什么是“跨进程 API Hook”? 众所周知Windows应用程序的各种系统功能是通过调用API函数来实现.API Hook就是给系统的API附加上一段小程序,它能监视甚至控制应用程序对API函数的 ...

  7. Android零基础入门第49节:AdapterViewFlipper图片轮播

    原文:Android零基础入门第49节:AdapterViewFlipper图片轮播 上一期学习了ExpandableListView的使用,你已经掌握了吗?本期开始学习AdapterViewFilp ...

  8. DDD中的值对象如何用NHibernate进行映射

    原文:DDD中的值对象如何用NHibernate进行映射 <component/>是NHibernate中一个有趣的特性,即是用来映射DDD(Data-Display-Debuger)概念 ...

  9. 什么是Android NDK

    1.NDK是一系列工具的集合. NDK提供了一系列的工具,帮助开发者快速开发C(或C++)的动态库,并能自动将so和java应用一起打包成apk.这些工具对开发者的帮助是巨大的. NDK集成了交叉编译 ...

  10. qt源码的submodules要怎么使用

    请问我下载了submodules里面的源代码,怎么使用?http://download.qt.io/official_releases/qt/5.7/5.7.1/submodules/如下载了qweb ...