# include <stdio.h>
# include <algorithm>
using namespace std;
int main()
{
int n,m,i,sum,cot,flag,j;
int map[80040];
int a[40010];
int ans1;
int ans2;
while(~scanf("%d%d",&n,&m))
{
ans1=ans2=40010;
memset(map,0,sizeof(map));
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]==m)
flag=i;
}
cot=0;
map[ans2]=1;
for(j=flag+1;j<=n;j++)
{
if(a[j]>m)
map[++ans1]++; //记录出现该状态的次数
else
map[--ans1]++;
}
cot+=map[ans2];//当状态数为ans2,才满足中位数
for(j=flag-1;j>=1;j--)
{
if(a[j]<m)
{
cot+=map[++ans2];
}
else
{
cot+=map[--ans2];
}
}
printf("%d\n",cot);
}
return 0;
}

hdu 4908 BestCoder Sequence的更多相关文章

  1. hdu 4908 BestCoder Sequence 发现M中值是字符串数, 需要预处理

    BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  2. [BestCoder Round #3] hdu 4908 BestCoder Sequence (计数)

    BestCoder Sequence Problem Description Mr Potato is a coder. Mr Potato is the BestCoder. One night, ...

  3. hdu4908 &amp; BestCoder Round #3 BestCoder Sequence(组合数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4908 BestCoder Sequence Time Limit: 2000/1000 MS (Jav ...

  4. BestCoder3 1002 BestCoder Sequence(hdu 4908) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4908 题目意思:给出 一个从1~N 的排列你和指定这个排列中的一个中位数m,从这个排列中找出长度为奇数 ...

  5. 【HDU】4908 (杭电 BC #3 1002题)BestCoder Sequence ——哈希

    BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  6. BestCoder Sequence

    hdu  4908  Bestcoder Problem Description Mr Potato is a coder.Mr Potato is the BestCoder. One night, ...

  7. hdu 5667 BestCoder Round #80 矩阵快速幂

    Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536 ...

  8. hdu 4908(思路题)

    BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  9. HDU 5860 Death Sequence(死亡序列)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

随机推荐

  1. 【Android 应用开发】 ActionBar 样式详解 -- 样式 主题 简介 Actionbar 的 icon logo 标题 菜单样式修改

    作者 : 万境绝尘 (octopus_truth@163.com) 转载请著名出处 : http://blog.csdn.net/shulianghan/article/details/3926916 ...

  2. How to center anything with css

    1. 绝对居中定位技术 我经常用margin:0 auto来实现水平居中,而一直认为margin:auto不能实现垂直居中……实际上,实现垂直居中仅需要声明元素高度和下面的CSS 优点:  缺点: 1 ...

  3. JavaScript学习笔记:检测数组方法

    检查数组的方法 很多时候我们需要对JavaScript中数据类型(Function.String.Number.Undefined.Boolean和Object)做判断.在JavaScript中提供了 ...

  4. CSS3滤镜filter浅析

    在实现特定显示效果的页面中,css的filter属性是一种强大的工具.它能让我们的页面更加地个性化并减少PS方面的工作.filter的属性值主要有以下十种: blur grayscale sepia ...

  5. TFS 用户与组管理(转)

    作者:frank.liu kaka.zhou 安装 Team Foundation Server 后,会创建以下全局组.可以使用这些全局组来控制 Team Foundation 用户的权限. 组 权限 ...

  6. Geodatabase - 判断是否处于编辑状态

    Engine中提供IDatasetEdit来判断数据是否处于编辑状态,我们知道,在ArcMap中,进行编辑的不一定都是要素类,也可以是表,网络几何等.以下能在ArcMap中进行编辑的数据都实现了 ID ...

  7. 利用“参数赋值”防范SQL注入漏洞攻击

    <<年轻,无权享受>————送给每一个看到此文的同僚们 在这无精打采的炎夏 我躺在阳台上房东的旧沙发 回想几个月来遇到的问题 我不禁内心开始慌张喘着粗气 还有大把时间去打拼 没有到只 ...

  8. TOJ3596 二维背包

    3596.   Watch The Movie Time Limit: 2.0 Seconds   Memory Limit: 65536KTotal Runs: 424   Accepted Run ...

  9. 安装laravel

    # 安装laravel 安装composer #安装 curl -sS https://getcomposer.org/installer | php #添加到PATH sudo mv compose ...

  10. 【面试】Spring问答Top 25

    本文由 ImportNew - 一直在路上 翻译自 howtodoinjava.欢迎加入翻译小组.转载请见文末要求. 本人收集了一些在大家在面试时被经常问及的关于Spring的主要问题,这些问题有可能 ...