#include
<
iostream
>
using
namespace
std;
int
n,k,a;
int
c[
10001
];
int
MAX,I;
int
lowbit(
int
x){
return
x
^
(x
&
(x
-
1
));
}
int
getsum(
int
x){
int
sum
=
0
;
while
(x){
sum
+=
c[x];
x
-=
lowbit(x);
}
return
sum;
}
void
modify(
int
x,
int
s){
while
(x
<=
n){
c[x]
+=
s;
x
+=
lowbit(x);
}
}
int
main()
{
scanf(
"
%d%d
"
,
&
n,
&
k);
MAX
=-
1
;
for
(
int
di
=
1
;di
<=
k;
++
di){
for
(
int
i
=
1
;i
<=
n;
++
i) c[i]
=
0
;
int
s
=
0
;
for
(
int
i
=
1
;i
<=
n;
++
i){
scanf(
"
%d
"
,
&
a);
s
+=
(a
-
1
)
-
getsum(a
-
1
);
modify(a,
1
);
}
if
(s
>
MAX){
MAX
=
s;
I
=
di;
}
}
printf(
"
%d\n
"
,I);
return
0
;
}
posted on 2009-05-29 23:42
xfstart07 阅读(110)
评论(0) 编辑 收藏 引用