记录编号 |
38820 |
评测结果 |
AAAAAAAAAA |
题目名称 |
工作指派 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
1.132 s |
提交时间 |
2012-06-14 20:57:59 |
内存使用 |
1.69 MiB |
显示代码纯文本
- const
- maxn=100000000000000000;
-
- var
- i,j:longint;
- n,k,c,max,min:int64;
- a,f:Array[0..100000]of int64;
-
- procedure sort(l,r:longint);
- var
- i,j,x,y:longint;
- begin
- x:=a[(l+r) div 2];
- i:=l;
- j:=r;
- repeat
- while a[i]<x do inc(i);
- while x<a[j] do dec(j);
- if i<=j then
- begin
- y:=a[i];
- a[i]:=a[j];
- a[j]:=y;
- inc(i);
- dec(j);
- end;
- until i>j;
- if i<r then sort(i,r);
- if l<j then sort(l,j);
- end;
-
-
- begin
- assign(input,'dividea.in'); reset(input);
- assign(output,'dividea.out'); rewrite(output);
- readln(n,k,c);
- for i:=1 to n do read(a[i]);
- sort(1,n);
- f[1]:=c;
- for i:=2 to n do
- begin
- f[i]:=maxn;
- for j:=i-k+1 downto 1 do
- begin
- if f[j-1]+c+sqr(a[i]-a[j])<f[i] then f[i]:=f[j-1]+c+sqr(a[i]-a[j]);
- end;
- end;
- writeln(f[n]);
- close(input);
- close(output);
- end.