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 ...
随机推荐
- [置顶] 【Git入门之九】解决冲突
原创作品,转载请标明:http://blog.csdn.net/jackystudio/article/details/12309531 1.多人协作冲突 如果多人同时修改了同一个文件,那会出现什么样 ...
- ORACLE 索引概述
索引是数据库中一种可选的数据结构,她通常与表或簇相关.用户可以在表的一列或数列上建立索引,以提高在此表上执行 SQL 语句的性能.就像本文档的索引可以帮助读者快速定位所需信息一样,Oracle 的索引 ...
- 浅谈MVC模式
MVC模式(三层架构模式) (Model-View-Controller)是软件工程中的一种软件架构模式,把软件系统分为三个基本部分:模型(Model).视图(View)和控制器(Controller ...
- 再谈javascript原型继承
Javascript原型继承是一个被说烂掉了的话题,但是自己对于这个问题一直没有彻底理解,今天花了点时间又看了一遍<Javascript模式>中关于原型实现继承的几种方法,下面来一一说明下 ...
- POJ3422 Kaka's Matrix Travels 【最大费用最大流】
Kaka's Matrix Travels Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8006 Accepted: ...
- 使用Intent实现Activity的显式跳转
[正文] 这里以按钮实现活动跳转为例,为实现这个功能,我们需要三个步骤: 1.点击按钮才发生页面跳转,因此,第一步我们先要找到要点击的按钮 如何拿到按钮对象呢?通过资源id,前面我们提到过,在R.id ...
- INFORMATION_SCHEMA.COLUMNS 查询表字段语句
INFORMATION_SCHEMA.COLUMNS 视图以 sysobjects.spt_data type_info.systypes.syscolumns.syscomments.sysconf ...
- Java基础知识强化72:正则表达式之判断功能(手机号码判断 和 校验邮箱)
1. 判断功能: 使用了String类的matches方法,如下: public boolean matches(String regex): 2. 判断手机号码的案例: package cn.it ...
- Python元组、列表--笔记
<Python3 程序开发指南> 序列包括元组和列表,首先,我们介绍元组. 元组--tuple 元组为有序的序列,元组和字符串一样也是固定的,不能替换或删除其中的任意数据项.如果需要修改应 ...
- css08盒子模型
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...