Ural 1090. In the Army Now
来源:互联网 发布:iptv网络电视catv888 编辑:程序博客网 时间:2024/05/19 08:42
#include <iostream>#include <cstdio>#include <cstring>#include <map>#include <set>#include <stack>#include <queue>using namespace std;const int maxn=10010;int sum;int f[maxn*4];void Build(int n){ sum=0; n=n<<2; for(int i=0;i<=n;i++) f[i]=0;}void update(int t,int l,int r,int k){ f[t]++; if(l==r-1) return; int mid=(l+r)/2; if(mid<k) { sum+=f[t<<1]; update(t<<1|1,mid,r,k); } else { update(t<<1,l,mid,k); }}int main(){ //freopen("data","r",stdin); int n,m; scanf("%d%d",&n,&m); int ans=0,pre=n*n,a; for(int i=1;i<=m;i++) { Build(n); for(int j=0;j<n;j++) { scanf("%d",&a); update(1,0,n,a); } if(pre>sum) { pre=sum; ans=i; } } printf("%d\n",ans); return 0;}
给出k个序列,求那个序列的逆序对最多。
用线段树求逆序对,树状数组也可以。
- Ural 1090. In the Army Now
- Ural 1090. In the Army Now
- ural 1090. In the Army Now
- URAL 1090. In the Army Now
- In the army now
- In the Army Now
- 1090. In the Army Now (Ural 1090 归并排序||树状数组)
- Uval 1090. In the Army Now
- Ural1090-In the Army Now
- 【逆序对】In the Army Now
- SOJ 2309: In the Army Now 树状数组求逆序对
- soj 2309: In the Army Now (树状数组求逆序数)
- CF587C Duff in the Army
- codeforces587C Duff in the Army
- URAL 1774 Barber of the Army of Mages 网络流
- Codeforces 587C Duff in the Army
- CF #326 (Div. 2) E Duff in the Army
- Codeforces Round #326 (Div. 1) C. Duff in the Army
- 由.def文件生成lib文件
- Google Chrome中的高性能网络(一)
- [进程管理]Load和CPU利用率是如何算出来的
- Windows 命令集合
- UVa 490 Rotating Sentences(旋转句子)
- Ural 1090. In the Army Now
- Java使用OSCache
- NSMutableDictionary
- 黑马程序员—java面向对象总结(4)—内部类、异常
- RTOS嵌入式学习
- 那些年黑了你的微软BUG
- 获取url后面的文件名
- c++中运算符的重载
- 管理絮语(感悟)