http://acm.timus.ru/problem.aspx?space=1&num=1090

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 20000
using namespace std; int c[maxn],n,a[maxn];
int lowbit(int x)
{
return x&(-x);
} void add(int pos)
{
while(pos<=n)
{
c[pos]++;
pos+=lowbit(pos);
}
} int sum1(int pos)
{
int sum=;
while(pos>)
{
sum+=c[pos];
pos-=lowbit(pos);
}
return sum;
} int main()
{
int m;
scanf("%d%d",&n,&m);
int max1=-,x;
for(int i=; i<=m; i++)
{
memset(c,,sizeof(c));
for(int j=; j<=n; j++)
{
scanf("%d",&a[j]);
}
int s=;
for(int j=n; j>=; j--)
{
add(a[j]);
s+=sum1(a[j]-);
}
if(s>max1){max1=s; x=i;}
}
printf("%d\n",x);
return ;
}

ural 1090 In the Army Now的更多相关文章

  1. URAL 1774 A - Barber of the Army of Mages 最大流

    A - Barber of the Army of MagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/v ...

  2. Ural 1774 Barber of the Army of Mages 最大流

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1774 1774. Barber of the Army of Mages Time li ...

  3. poj 3069 Saruman's Army

    Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8477   Accepted: 4317 De ...

  4. poj3069 Saruman's Army

    http://poj.org/problem?id=3069 Saruman the White must lead his army along a straight path from Iseng ...

  5. 1472. Martian Army

    http://acm.timus.ru/problem.aspx?space=1&num=1472 题目大意: 一颗树,根节点(1) 的值为 1.0,所有叶子节点的值为 0.0 ,其他节点值任 ...

  6. BZOJ 1090: [SCOI2003]字符串折叠

    Sol 区间DP. 转移很简单,枚举会形成的断长转移就行,话说上一题我就跟这个是差不多的思路,转移改了改,然后死活过不了... 同样都是SCOI的题...相差4年... Code /********* ...

  7. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  8. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  9. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

随机推荐

  1. Emacs学习阶段小结-Emacs常用快捷键总结

    首先推荐一下Emacs自带的Emacs Tutorial,跟着这个做一边,两三个小时,基本的使用就能掌握了.之后的神教程就有很多了,比如<Sams.Teach.Yourself.Emacs.in ...

  2. javascript获取对应页面的代码

    window.onload = function () { function getUrls(url) {//核心代码是url2这行代码,通过.replace()方法将对应的字符串替换成其他方式 va ...

  3. 写自己的WPF样式 - 按钮

    做一个后台管理小程序,据说WPF的界面比较"炫",于是选择使用WPF来开发.既然用了WPF当然需要做好看点了,于是稍微研究了下WPF的样式,废话不多说下面开始自定义一个按钮样式: ...

  4. atitit.提升研发效率的利器---重型框架与类库的差别与设计原则

    atitit.提升研发效率的利器---重型框架与类库的差别与设计原则 1. 框架的意义---设计的复用 1 1.1. 重型框架就是it界的重武器. 1 2. 框架 VS. 库 可视化图形化 1 2.1 ...

  5. 36th成都区域赛网络赛 hdoj4039 The Social Network(建图+字符串处理)

    这题是某年成都区域赛网络赛的一题. 这题思路非常easy,可是从时间上考虑,不妨不要用矩阵存储,我用的链式前向星. 採用线上查询.利用map对字符串编号,由于非常方便.要推荐的朋友,事实上就是朋友的朋 ...

  6. C语言单元測试

    C语言单元測试 对于敏捷开发来说,单元測试不可缺少,对于Java开发来说,JUnit非常好,对于C++开发,也有CPPUnit可供使用,而对于传统的C语言开发,就没有非常好的工具可供使用,能够找到的有 ...

  7. Java – 4 Security Vulnerabilities Related Coding Practices to Avoid---reference

    This article represents top 4 security vulnerabilities related coding practice to avoid while you ar ...

  8. mysql myisam 锁表问题<转>

    转自http://yafei001.iteye.com/blog/1841258 锁是计算机协调多个进程或线程并发访问某一资源的机制 .在数据库中,除传统的计算资源(如CPU.RAM.I/O等)的争用 ...

  9. Mui实现退出登录

    document.getElementById("logout").addEventListener("tap",function(){ var btn=[&q ...

  10. 10、第十节课jq420151012

    1.点击交替显示隐藏功能  点击交替执行的:fadeToggle(1000) , slideToggle() ,  toggle(1000);      2.点击单独执行    单独显示/隐藏:sho ...