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. 二、Linux文件系统之内存管理

    虚拟内存  32位:4G 64位:2^64 内存管理: 进程管理 自动分配和管理 支持模块化程序设计 保护和访问控制 长期存储 虚拟内存  <---MMU-->物理内存

  2. Object-C @synthesize -- 笔记

  3. django 执行原始SQL

    二.知识点总结 When the model query APIs don’t go far enough, you can fall back to writing raw SQL. go far ...

  4. Oralce新建数据库、新建远程登录用户全过程

    Oracle安装完后,其中有一个缺省的数据库,除了这个缺省的数据库外,我们还可以创建自己的数据库.     对于初学者来说,为了避免麻烦,可以用'Database Configuration Assi ...

  5. JNI调用native方法出现 java.lang.UnsatisfiedLinkError: XXXclass.XXXmethod()异常的解决办法

    昨天拿到JNI的Android工程Demo,然后把demo整合到开发的主线工程上,发现调用JNI方法一直抛同一个异常 java.lang.UnsatisfiedLinkError: XXXclass. ...

  6. Unity3D之MeleeWeaponTrail武器轨迹插件的使用

    MeleeWeaponTrail是Unity Asset Store中的一个免费插件.主要是用于显示武器的轨迹. 首先,找到武器绑定的骨骼.并在骨骼以下加入轨迹显示的起点和终点. 接着,给该骨骼加入M ...

  7. [Redux] Introduction

    Single immutable state tree: Should be just one single javascript object. Describing the changes by ...

  8. Configuring the JA-SIG CAS Client --官方

    1. for Java using Spring Configuration of the CAS Client for Java via Spring IoC will depend heavily ...

  9. [转] vim 正则表达式 很强大

    毋庸多言,在vim中正则表达式得到了十分广泛的应用. 最常用的 / 和 :s 命令中,正则表达式都是不可或缺的. 下面对vim中的正则表达式的一些难点进行说明. 关于magic vim中有个magic ...

  10. Counting Lines, Words, and Characters with wc

      Counting Lines, Words, and Characters with wc   When working with text files, you sometimes get a ...