LA4329
来源:互联网 发布:ubuntu 14.04 qq 2015 编辑:程序博客网 时间:2024/05/22 07:01
UVALive - 4329
[Submit]
Description
N
Input
The first line of the input contains an integer
Every test case consists of
Output
For each test case, output a single line contains an integer, the total number of different games.
Sample Input
13 1 2 3
Sample Output
1
解题报告
http://vjudge.net/problem/viewProblem.action?id=13895
大白书 197页
lmin[i]求i左边比i小的数的个数
#include<stdio.h>#include<string.h>#include<iostream>#define lowbit(x) (x &(-x))using namespace std;const int M = 100005;const int N = 20005;int c[M],a[N],lmin[N],rmin[N];void add (int x){ while (x <= M) c[x] += 1,x += lowbit(x);}int sum(int x){ int res = 0; while (x > 0) res += c[x],x -= lowbit(x); return res;}int main (){ int T,n,i; scanf ("%d",&T); while (T--) { scanf ("%d",&n); memset (c,0,sizeof(c)); for (i = 1; i <= n; i ++) { scanf ("%d",&a[i]); add(a[i]); lmin[i] = sum(a[i]-1); } for( i=1;i<=n;i++) cout<<lmin[i]<<'*'; memset (c,0,sizeof(c)); for (i = n; i >= 1; i --) { add(a[i]); rmin[i] = sum(a[i]-1); } long long ans = 0; for (i = 1; i <= n; i ++) ans += lmin[i]*(n-i-rmin[i])+(i-lmin[i]-1)*rmin[i]; printf ("%lld\n",ans); } return 0;}
- LA4329
- LA4329
- LA4329
- la4329 例题 小问题
- Ping pong LA4329
- POJ3928、LA4329【树状数组】
- LA4329(树状数组)
- LA4329 乒乓 树状数组
- LA4329 Ping pong
- LA4329(树状数组)
- LA4329-乒乓比赛
- LA4329(树状数组)
- LA4329树状数组
- LA4329 树状数组
- LA4329:Ping pong(树状数组)
- LA4329 Ping pong(树状数组)
- 树状数组之--LA4329 Ping pong
- 树状数组(LA4329,UVaLive4329,Ping pong)
- CSU_1409: 集合的并
- maven 可用仓库网址
- 在debian 安装 vm tool
- 学习https的总结
- 巧妇能为少米之炊(1)——Android下小内存下的生存之道
- LA4329
- Android回顾之静默安装
- Android的framework层音量控制原理分析--hot(key)处理
- 好文分享
- 解析Obj-C中的assgin,copy,retain关键字的含义。
- 七(7.6 ) 线程的执行时间
- OCX控件包装类的生成
- 使用TabHost实现卡片选项菜单
- 抑郁症患者的陈述