ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1026. Questions and Answers

Help!!! Time Limit!!!
Posted by Vladzick 27 Nov 2007 16:26
here is my program

var a,b:array[1..100000] of longint;
    i,k,l,n,m:longint;
    f1,f2:text;
    s:string;
begin
    readln(n);
    for i:=1 to n do
      readln(a[i]);
    readln(s);
    readln(m);
    for k:=1 to m do
      readln(b[k]);
    for k:=1 to n do
      for i:=2 to n do
        if a[i]<a[i-1] then begin l:=a[i]; a[i]:=a[i-1]; a[i-1]:=l; end;
    for i:=1 to m do
    writeln(a[b[i]]);
    readln;
end.
Re: Help!!! Time Limit!!!
Posted by KIRILL(ArcSTUpid coder:) 27 Nov 2007 18:52
You should use fast sort
buble sort too long

qsort fast enough
Re: Help!!! Time Limit!!!
Posted by DR. Zhihua Lai 30 Nov 2011 03:08
use hash, no necessary to sort actually.