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 |
Re:我也发发In Reply To:Ac 100 题留念!(没想到是道水题) Posted by:IceKingdom at 2008-10-04 13:13:53 type arr=array[1..50000]of longword; var n,k,i,maxx,nk:longint;a,b:arr;max:longword;c:array[1..50000]of 1..50000; procedure qsort(l,r:longint); var i,j,m,p:longint; begin i:=l;j:=r;m:=a[l]; repeat while a[i]<m do inc(i); while a[j]>m do dec(j); if i<=j then begin p:=a[i];a[i]:=a[j];a[j]:=p;p:=b[i];b[i]:=b[j];b[j]:=p; p:=c[i];c[i]:=c[j];c[j]:=p;inc(i);dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r); end; begin readln(n,k); for i:=1 to n do begin readln(a[i],b[i]);c[i]:=i;end; qsort(1,n); max:=b[n];maxx:=n; nk:=n-k+1; for i:=n downto nk do if b[i]>max then begin max:=b[i]; maxx:=i; end; writeln(c[maxx]); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator