ural 1090 In the Army Now
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的更多相关文章
- 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 ...
- 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 ...
- poj 3069 Saruman's Army
Saruman's Army Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8477 Accepted: 4317 De ...
- poj3069 Saruman's Army
http://poj.org/problem?id=3069 Saruman the White must lead his army along a straight path from Iseng ...
- 1472. Martian Army
http://acm.timus.ru/problem.aspx?space=1&num=1472 题目大意: 一颗树,根节点(1) 的值为 1.0,所有叶子节点的值为 0.0 ,其他节点值任 ...
- BZOJ 1090: [SCOI2003]字符串折叠
Sol 区间DP. 转移很简单,枚举会形成的断长转移就行,话说上一题我就跟这个是差不多的思路,转移改了改,然后死活过不了... 同样都是SCOI的题...相差4年... Code /********* ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
随机推荐
- selenium webdriver python 等待
AJAX,即“Asynchronous Javascript And XML”.可以实现网页的异步更新.也就是在不重新加载整个网页的情况下,对网页的某部分进行更新. 现在大多数网站都使用AJAX技术 ...
- Js菜鸟学习
(一) 1 代码如下: //页面中写入html内容 document.write("<h1>Hello World!</h1>") 2 代码如下: //为了 ...
- 跟Google学习Android开发-起始篇-构建你的第一个应用程序(4)
说明:此系列教程翻译自Google Android开发者官网的Training教程,利用Chome浏览器的自动翻译功能作初译,然后在一些语句不顺或容易造成误解的地方作局部修正.方便英文不好的开发者查看 ...
- SKTexture类
继承自 NSObject 符合 NSCodingNSCopyingNSObject(NSObject) 框架 /System/Library/Frameworks/SpriteKit.framewo ...
- tomcat安全配置之禁用Directory Listing
什么是Directory Listing?通俗点讲,就是在webapp的目录下如果没有放置index.html或者类似的文件,如果从IE或者其它浏览器文章这个路径时,会惊喜的发现这个目录下的文件列表被 ...
- 10 Powerful Apache Modules--reference
Apache is the most popular web server in the world,because it is more efficient than others.Thrust o ...
- [转] 在 Linux 中怎样使用cp命令合并目录树
PS:通过cp -r --link a/* b/* merged 硬链接不需要复制 怎样将两个布局相似的目录树合并成一个新的目录树?为理解该问题让我们思考下面的例子. 假设 dir1 和 dir2 目 ...
- IPC进程间通信 - AIDL+Binder
原理 http://www.linuxidc.com/Linux/2012-07/66195.htm 服务端,客户端处在用户空间,而binder驱动处在内核空间. 服务器端.一个Binder服 ...
- linux 网络状态工具ss命令
ss命令用于显示socket状态. 他可以显示PACKET sockets, TCP sockets, UDP sockets, DCCP sockets, RAW sockets, Unix dom ...
- Linux下python升级
Centos即使用Yum更新也是Python2.6.6所以需要升级到Python2.7.8 1.先下载源码包 1 wget https://www.python.org/ftp/python/2.7. ...