| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Ac 100 题留念!(没想到是道水题)program p3664;
type cowtype=record a,b,w:longint; end;
var n,k,ans,i,president:longint;
cow:array[1..60000]of cowtype;
procedure qsort(s,t:longint);
var i,j:longint; d,x:cowtype;
begin
i:=s; j:=t; x:=cow[(s+t) shr 1];
repeat
while cow[i].a>x.a do inc(i);
while cow[j].a<x.a do dec(j);
if i<=j then begin d:=cow[i]; cow[i]:=cow[j]; cow[j]:=d; inc(i); dec(j); end;
until i>j;
if s<j then qsort(s,j); if i<t then qsort(i,t);
end;
begin
assign(input,'t3664.in'); reset(input); assign(output,'t3664.out'); rewrite(output);
readln(n,k);
for i:=1 to n do begin readln(cow[i].a,cow[i].b); cow[i].w:=i; end;
qsort(1,n);
ans:=-1;
for i:=1 to k do
if cow[i].b>ans
then begin ans:=cow[i].b; president:=cow[i].w; end;
writeln(president);
close(input); close(output);
end.
qsort 中交换变量d打成了x。wa了一次。。。太激动了
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator