求大牛看看哪WA了

{var
ans,i,s,n:longint;
a:array[1..10000]of longint;
procedure sort(l,r:longint);
var
i,j,t,mid:longint;
begin
i:=l;
j:=r;
mid:=a[(i+j)div 2];
while i<=j do
begin
while a[i]<mid do inc(i);
while a[j]>mid do dec(j);
t:=a[i];
a[i]:=a[j];
a[j]:=t;
inc(i);
dec(j);
end;
if i<r then sort(i,r);
if j>l then sort(l,j);
end;
begin
ans:=0;
readln(n);
for i:=1 to n do read(a[i]);
sort(1,n);
s:=a[1];
for i:=2 to n do
begin
s:=s+a[i];
ans:=ans+s;
end;
writeln(ans);
end. }
var
s,i,j,k,p,a,ans:longint;
n:array[1..10000]of longint;
begin
s:=maxlongint;
readln(a);
for i:=1 to a do
begin
read(n[i]);
if n[i]<s then
begin
s:=n[i];
k:=i;
end;
end;
n[k]:=maxlongint;
i:=1;
repeat
inc(i);
p:=maxlongint;
for j:=1 to a do
begin
if p>n[j] then
begin
p:=n[j];
n[j]:=maxlongint;
end;
end;
s:=s+p;
ans:=ans+s;
until i=a;
writeln(ans);
end.
什么情况,求大牛赐教谢谢

3 条评论

  • 1

信息

ID
1097
难度
6
分类
贪心 点击显示
标签
递交数
23906
已通过
6330
通过率
26%
被复制
41
上传者