思路:统计当前数左边比它小|大 i个人,相应右边就应该是比它大|小i个人

l数组表示左边i个人的方案

r表示右边i个人的方案

数组下标不可能是负数所以要加n

 //#pragma comment(linker, "/STACK:167772160")//手动扩栈~~~~hdu 用c++交
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
// #include<malloc.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define LL long long
const int inf = 0x3f3f3f3f;
const double eps = 1e-;
const double pi = acos(-);
const LL MOD = 1e9+;
// const LL p = 1e9+7;
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// } int numm[],sum[],l[],r[];
int n,point,ans,b;
int a[]; int main() {
while(~scanf("%d",&n)) {
for(int i=; i<=n; i++) scanf("%d",&a[i]); for(int j=; j<=n; j++) {
b=a[j];
for(int i=;i<=n;i++) numm[i]=a[i];
// for(int i=0;i<=n;i++) l[i]=0;
// for(int i=0;i<=n;i++) r[i]=0;
// for(int i=0;i<=n;i++) sum[i]=0;
clc(l,);
clc(r,);
clc(sum,);
ans=;
for(int i=; i<=n; i++) {
if(numm[i]>b) numm[i]=;
else if(numm[i]==b) {
numm[i]=;
point=i;
} else numm[i]=-;
}
l[n]=;
r[n]=;
for(int i=point-; i>=; i--) {
sum[i]=sum[i+]+numm[i];
l[sum[i]+n]++;
}
for(int i=point+; i<=n; i++) {
sum[i]=sum[i-]+numm[i];
r[sum[i]+n]++;
}
for(int i=; i<=*n-; i++) ans+=l[i]*r[*n-i]; if(j==)
printf("%d",ans);
else
printf(" %d",ans);
}
printf("\n");
}
return ;
}

2016"百度之星" - 初赛(Astar Round2B) 1006 中位数计数的更多相关文章

  1. 2016百度之星-初赛(Astar Round2A)AII X

    Problem Description F(x,m) 代表一个全是由数字x组成的m位数字.请计算,以下式子是否成立: F(x,m) mod k ≡ c Input 第一行一个整数T,表示T组数据. 每 ...

  2. 2016"百度之星" - 初赛(Astar Round2A)HDU 5695 拓扑排序+优先队列

    Gym Class Time Limit: 6000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  3. 2016百度之星 初赛2A ABEF

    只做了1001 1002 1005 1006.剩下2题可能以后补? http://acm.hdu.edu.cn/search.php?field=problem&key=2016%22%B0% ...

  4. HDU 5690:2016"百度之星" - 初赛 All X

    原文链接:https://www.dreamwings.cn/hdu5690/2657.html All X Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  5. 2016百度之星 初赛2B ACEF

    做了1001 1003 1005 1006 看题:http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=702 交题:http://acm ...

  6. 2016"百度之星" - 初赛(Astar Round2B)

    Problem Description 中位数定义为所有值从小到大排序后排在正中间的那个数,如果值有偶数个,通常取最中间的两个数值的平均数作为中位数. 现在有n个数,每个数都是独一无二的,求出每个数在 ...

  7. 2016"百度之星" - 初赛(Astar Round2B)1003 瞬间移动 组合数学+逆元

    瞬间移动  Accepts: 1018  Submissions: 3620  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 65536/ ...

  8. 2016"百度之星" - 初赛(Astar Round2A) 1006 Gym Class 拓扑排序

    Gym Class  Time Limit: 6000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) Problem ...

  9. hdu5696区间的价值 -- 2016"百度之星" - 初赛(Astar Round2B)

    Problem Description 我们定义“区间的价值”为一段区间的最大值*最小值. 一个区间左端点在L,右端点在R,那么该区间的长度为(R−L+1). 现在聪明的杰西想要知道,对于长度为k的区 ...

随机推荐

  1. XoftSpy 4.13的注册算法分析

    [标题]XoftSpy 4.13的注册算法分析 [作者]forever[RCT] [语言]VC [工具]ida4.6,ollydbg1.1 [正文]       这个软件的算法很简单,正好拿来做逆向分 ...

  2. [Unity+Android]横版扫描二维码

    原地址:http://blog.csdn.net/dingxiaowei2013/article/details/25086835 终于解决了一个忧伤好久的问题,严重拖了项目进度,深感惭愧!一直被一系 ...

  3. POJ3034+DP

    题意:给定一个N*N的矩阵, 然后在这个矩阵的每个格子在任意时间会出现一个鼹鼠,这个出现     出现鼹鼠的时间是输出信息所确定的. 现在你手里有一把锤子能够去锤这些鼹鼠. 你能     够移动锤子, ...

  4. highcharts 柱状图

    <!doctype html> <html lang="en"> <head> <script type="text/javas ...

  5. SaaS系列介绍之九: SaaS营销模式分析

    1 配置模式 中国企业很多是人治,管理弹性非常大,公司的政策经常变化,管理流程.业务变化也非常大,发展也非常快;一个公司今年是10个人,明年是100个人,后年可能是1000人.管理机制.方法处于经常变 ...

  6. ids & hdmi 原理

    http://www.taiwanwebinar.com/zh_TW/STATIC/SITE/dwc_hdmi_tx.pdf http://blog.csdn.net/g_salamander/art ...

  7. Qt之自定义控件(开关按钮)Qt之模拟时钟

    http://blog.csdn.net/u011012932/article/details/52164289 http://blog.csdn.net/u011012932/article/det ...

  8. HTML5 JS API 本地存储LocalStorage基本操作

    LocalStorage:使用方法与SessionStorage如出一辙,如下代码所示:此对象主要有两个方法:保存数据:localStorage.setItem(Key, value);读取数据:lo ...

  9. 转载 .htaccess文件RewriteRule语法规则

    详见: http://blog.csdn.net/scchary/article/details/40045807    # -- 位于行首时表示注释.       [F] -- Forbidden( ...

  10. Android开发之技术文章索引

    Activity: 1.PreferenceActivity Fragment: 1.fragment中套用PagerSlidingTabStrip,切换底部时viewpager消失的解决 Widge ...