| ||||||||||
| 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 | |||||||||
What's Wrong? Thx a lot...{
PROG:shelf
LANG:PASCAL
ID:kydmail1
}
program poj_shelf3627;
var
a:array [0..20000] of integer;
n,b,i,j:integer;
s:longint;
procedure qsort(s,t:integer);
var
i,j,mid:integer;
begin
i:=s;
j:=t;
mid:=a[s];
while (i<j) do
begin
while (i<j) and (a[j]>=mid) do dec(j);
if (i<j) then a[i]:=a[j];
while (i<j) and (a[i]<=mid) do inc(i);
if i<j then a[j]:=a[i];
end;
a[i]:=mid;
if s<i-1 then qsort(s,i-1);
if i+1<t then qsort(i+1,t);
end;
begin
{assign(input,'shelf.in');
assign(output,'shelf.out');
reset(input);
rewrite(output); }
readln(n,b);
fillchar(a,sizeof(a),0);
for i:=1 to n do
readln(a[i]);
qsort(1,n);
s:=0;
for i:=1 to n do
begin
s:=s+a[n-i+1];
if s>=b then break;
end;
writeln(i);
{close(output);}
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator