/ SB域 /

记录详情

Accepted

/usr/bin/ld.bfd: warning: /out/link.res contains output sections; did you forget -T?
# 状态 耗时 内存占用
#1 Accepted 1ms 256.0 KiB
#2 Accepted 1ms 256.0 KiB
#3 Accepted 1ms 256.0 KiB
#4 Accepted 1ms 256.0 KiB
#5 Accepted 1ms 256.0 KiB
#6 Accepted 1ms 256.0 KiB
#7 Accepted 1ms 256.0 KiB
#8 Accepted 1ms 256.0 KiB
#9 Accepted 1ms 256.0 KiB
#10 Accepted 1ms 256.0 KiB

代码

var t1,t2,n,sum,i:longint;
    a:array[1..1000]of longint;
procedure qsort(l,r:longint);
var t,i,j,mid:longint;
begin
i:=l; j:=r;
mid:=a[(l+r)div 2];
while i<j do
begin
 while a[i]<mid do inc(i);
 while a[j]>mid do dec(j);
 if i<=j then begin
   t:=a[i]; a[i]:=a[j]; a[j]:=t;
   inc(i);dec(j);
 end;
end;
if l<j then qsort(l,j);
if r>i then qsort(i,r);
end;
begin

 readln(n);
 for i:=1 to n do read(a[i]);
 qsort(1,n);
// for i:=1 to n do write(a[i],' ');
 if n mod 2=1 then sum:=a[1]+a[2]+a[3]
 else sum:=a[2];
// for i:=n downto 3 do begin
 i:=n;
 while i>3 do begin
 t1:=a[2]+a[1]+a[i]+a[2];
 t2:=a[i]+a[1]+a[i-1]+a[1];
  if t1>t2 then t1:=t2;
  sum:=sum+t1;
  i:=i-2;
 end;
// end;
 writeln(sum);
 close(input);
 close(output);

end.

信息

递交者
类型
递交
题目
【模板】贪心的渡河
题目数据
下载
语言
Pascal
递交时间
2017-08-22 16:13:15
评测时间
2017-08-22 16:13:15
评测机
分数
100
总耗时
17ms
峰值内存
256.0 KiB