Codeforces 380E Sereja and Dividing
题面
题解
有精度要求所以只用求几十次就差不多了
CODE
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 300005;
struct node {
int v, id;
inline bool operator <(const node &o)const {
return v < o.v || (v == o.v && id < o.id);
}
}p[MAXN];
int n, pre[MAXN], nxt[MAXN];
int main () {
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d", &p[i].v), p[i].id = i, pre[i] = i-1, nxt[i] = i+1;
sort(p + 1, p + n + 1);
double ans = 0;
for(int i = 1; i <= n; ++i) {
double l = 0, r = 0, pw = 1;
int x = p[i].id, lp = x, rp = x;
for(int j = 1; j <= 50; ++j) {
pw /= 2;
if(lp) l += pw*(lp - pre[lp]), lp = pre[lp];
if(rp<=n) r += pw*(nxt[rp] - rp), rp = nxt[rp];
}
ans += 2*l*r*p[i].v;
nxt[pre[x]] = nxt[x];
pre[nxt[x]] = pre[x];
}
printf("%.15f\n", ans/n/n);
}
Codeforces 380E Sereja and Dividing的更多相关文章
- CodeForces 1249A --- Yet Another Dividing into Teams
[CodeForces 1249A --- Yet Another Dividing into Teams] Description You are a coach of a group consis ...
- codeforces 314E Sereja and Squares
discription Sereja painted n points on the plane, point number i (1 ≤ i ≤ n) has coordinates (i, 0). ...
- Codeforces 425A Sereja and Swaps(暴力枚举)
题目链接:A. Sereja and Swaps 题意:给定一个序列,能够交换k次,问交换完后的子序列最大值的最大值是多少 思路:暴力枚举每一个区间,然后每一个区间[l,r]之内的值先存在优先队列内, ...
- codeforces 425C Sereja and Two Sequences(DP)
题意读了好久才读懂....不知道怎么翻译好~~请自便~~~ http://codeforces.com/problemset/problem/425/C 看懂之后纠结好久...不会做...仍然是看题解 ...
- codeforces B. Sereja and Stairs 解题报告
题目链接:http://codeforces.com/problemset/problem/381/B 题目意思:给定一个m个数的序列,需要从中组合出符合楼梯定义 a1 < a2 < .. ...
- codeforces A. Sereja and Bottles 解题报告
题目链接:http://codeforces.com/problemset/problem/315/A 题目意思:有n个soda bottles,随后给出这n个soda bottles的信息.已知第 ...
- Codeforces 380A - Sereja and Prefixes
原题地址:http://codeforces.com/problemset/problem/380/A 让期末考试整的好久没有写题, 放假之后由于生病也没怎么做,新年的第一场CF也不是那么在状态,只过 ...
- codeforces C. Sereja and Swaps
http://codeforces.com/contest/426/problem/C 题意:找出连续序列的和的最大值,可以允许交换k次任意位置的两个数. 思路:枚举区间,依次把区间内的比较小的数换成 ...
- CodeForces - 314C Sereja and Subsequences (树状数组+dp)
Sereja has a sequence that consists of n positive integers, a1, a2, ..., an. First Sereja took a pie ...
随机推荐
- qt 旧项目编译运行提示 “启动程序失败,路径或者权限错误?” 原因及解决方法
qt 旧项目编译运行提示 "启动程序失败,路径或者权限错误?" 原因及解决方法 原因 Qt Creator在打开项目文件的同时会生成.pro.user文件,.pro.user文件叫 ...
- Oracle 11g xe版本---总结1
一.创建用户和授予权限 1.1 环境: Oracle 11g xe 第三方图形客户端: PLSQL Windows 10 必须登录 HR 用户,下面的查询会使用到 HR 中的表. 1.2 SQL 语句 ...
- 湖北校园网PC端拨号算法逆向
湖北校园网PC端拨号算法逆向 前言 上一文 PPPoE中间人拦截以及校园网突破漫谈我们谈到使用 PPPoE 拦截来获取真实的账号密码. 在这个的基础上,我对我们湖北的客户端进行了逆向,得到了拨号加密算 ...
- Scratch编程:画多边形(八)
“ 上节课的内容全部掌握了吗?反复练习了没有,编程最好的学习方法就是练习.练习.再练习.一定要记得多动手.多动脑筋哦~~” 01 — 游戏介绍 这节我们将实现:程序提示用户输入数据,然后根据用户的输入 ...
- DataSource配置
一.JDBC Jar依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifac ...
- core直接获取报异常数据
报异常直接跳转到/Home/Error [ResponseCache(Duration = , Location = ResponseCacheLocation.None, NoStore = tru ...
- SSH安全加固
SSH安全加固 配置文件: /etc/ssh/sshd_config # This file is automatically generated at startup KexAlgorithms c ...
- 《图解HTTP》读后总结
阅读时间:2019.10.30-2019.11.6 阅读心得: 从知乎上看到有人推荐这本书,本身对计算机网络方面学习的比较少,于是就买来这本书开始看.这本书总体看下来比较轻松,因为书中的插画非常卡通, ...
- .gitignore文件的写法
有些时候,你必须把某些文件放到Git工作目录中,但又不能提交它们,比如保存了数据库密码的配置文件啦,等等,每次git status都会显示Untracked files .... 解决的方法就是在gi ...
- 使用js解决response.sendRedirect("...")重定向URL之后出现跨域问题
背景: 本系统与门户系统单点登录时候,需要重定向到门户系统的登录页面,可是如果长时间没有操作的话,session会话失效,就需要跳转到登录页面. 所以在使用 response.sendRedirect ...