/ 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
#11 Accepted 1ms 256.0 KiB
#12 Accepted 1ms 256.0 KiB
#13 Accepted 1ms 256.0 KiB
#14 Accepted 1ms 256.0 KiB
#15 Accepted 1ms 256.0 KiB
#16 Accepted 1ms 256.0 KiB
#17 Accepted 1ms 256.0 KiB
#18 Accepted 1ms 256.0 KiB
#19 Accepted 1ms 256.0 KiB
#20 Accepted 1ms 256.0 KiB
#21 Accepted 1ms 256.0 KiB
#22 Accepted 1ms 256.0 KiB
#23 Accepted 1ms 256.0 KiB
#24 Accepted 1ms 256.0 KiB
#25 Accepted 1ms 256.0 KiB
#26 Accepted 1ms 256.0 KiB
#27 Accepted 1ms 256.0 KiB
#28 Accepted 1ms 256.0 KiB
#29 Accepted 0ms 256.0 KiB
#30 Accepted 1ms 256.0 KiB
#31 Accepted 1ms 256.0 KiB
#32 Accepted 1ms 256.0 KiB
#33 Accepted 0ms 256.0 KiB
#34 Accepted 0ms 256.0 KiB
#35 Accepted 0ms 256.0 KiB
#36 Accepted 0ms 256.0 KiB
#37 Accepted 0ms 256.0 KiB
#38 Accepted 0ms 256.0 KiB
#39 Accepted 0ms 256.0 KiB
#40 Accepted 0ms 256.0 KiB

代码

var n,k,p,i,cnt,min,stop,disk1,disk2,next,pre:longint;
    a,b:array[-10..10000]of longint;
function f(x,y,p:longint):longint;
var cnt:longint;
begin
 cnt:=0;
 while x<>y do begin
  inc(cnt);
  inc(x,p);
  if x=101 then x:=1;
  if x=0 then x:=100;
 end;
 exit(cnt);
end;
procedure swap(var a,b:longint);
var t:longint;
begin
t:=a; a:=b; b:=t;
end;
procedure qsort(l,r:longint);
var i,j,mid:longint;
begin
 i:=l; j:=r; mid:=(a[(l+r) div 2]);
 repeat
  while (a[i])<mid do inc(i);
  while (a[j])>mid do dec(j);
  if i<=j then begin
   swap(a[i],a[j]);
   inc(i);
   dec(j);
  end;
 until i>j;
 if i<r then qsort(i,r);
 if j>l then qsort(l,j);end;
begin
 readln(n,k);
 for i:=1 to n do read(a[i]);
 qsort(1,n);
 a[0]:=a[n];
 min:=maxlongint;
 for i:=1 to n do begin
  next:=(i+1)mod n;
  pre:=(i+n-1)mod n;
  disk1:=f(k,a[i],1);
  if f(k,a[next],1)>disk1 then
    disk1:=disk1+f(a[i],a[next],-1);
  disk2:=f(k,a[i],-1);
  if f(k,a[pre],-1)>disk2 then
    disk2:=disk2+f(a[i],a[pre],1);
  if disk1<min then min:=disk1;
  if disk2<min then min:=disk2;
 end;
 writeln(min);
 close(input);
 close(output);
end.

信息

递交者
类型
递交
题目
磁盘排程
题目数据
下载
语言
Pascal
递交时间
2017-08-22 16:00:27
评测时间
2017-08-22 16:00:27
评测机
分数
100
总耗时
51ms
峰值内存
256.0 KiB