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 ...
随机推荐
- C++根据用户输入打印对应的金层塔层数
#include <iostream> #include <Windows.h> using namespace std; int main(void) { int row; ...
- 几个有益的 CSS 小知识
样式的顺序 CSS 代码: HTML 代码: 记得之前这是一道比较火的 CSS 考题,当时好像是有不少的人答错(30% 以上) 答案你们应该是知道的. 可以这样提升 CSS 性能 后代选择器 ...
- 2.33模型--去除字符串两头空格.c
[注:本程序验证是使用vs2013版] #include <stdio.h> #include <stdlib.h> #include <string.h> #pr ...
- Arm-Linux 移植 alsa
ref : https://www.cnblogs.com/yutingliuyl/p/6718875.html https://blog.csdn.net/yuanxinfei920/article ...
- # RESTful登录(基于token鉴权)的设计实例
使用场景 现在很多基于restful的api接口都有个登录的设计,也就是在发起正式的请求之前先通过一个登录的请求接口,申请一个叫做token的东西.申请成功后,后面其他的支付请求都要带上这个token ...
- pdm文件打开方式
转自:https://blog.csdn.net/qq_36855191/article/details/79299216 pdm打开网站:http://www.dmanywhere.cn/
- vue使用技巧:Promise + async + await 解决组件间串行编程问题
业务场景描述 大家都通过互联网投递过简历,比如在智联.58.猎聘等平台.投递心仪的职位前一般都需要前提创建一份简历,简历编辑界面常规的布局最上面是用户的个人基本信息,如姓名.性别.年龄.名族等,接着是 ...
- DBShop前台RCE
前言 处理重装系统的Controller在判断是否有锁文件后用的是重定向而不是exit,这样后面的逻辑代码还是会执行,导致了数据库重装漏洞和RCE. 正文 InstallController.php中 ...
- Qt槽函数创建
法一 手动添加 private slots: void on_cancel_clicked(); void Widget::on_cancel_clicked() { } connect(ui-> ...
- nodejs 模块全局安装路径配置
nodejs下载安装完成后 输入npm config ls 或者npm config list npm 默认的全局安装路径为该路径,将包都下载在C盘中不是我们想要的结果.一般建议修改在nodejs的安 ...