记录编号 |
22360 |
评测结果 |
AAAAAAAAAA |
题目名称 |
分班 |
最终得分 |
100 |
用户昵称 |
magic |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.001 s |
提交时间 |
2010-11-18 18:38:53 |
内存使用 |
0.11 MiB |
显示代码纯文本
program gls;
var
ss:array[1..50]of int64;{ke neng yao gai}
a,b,c,k,n,he,sum1,sum2,p:longint;
f,g:text;
procedure Sort(l, r: longint);
var
i, j, x, y: longint;
begin
i := l; j := r; x := ss[(l+r) DIV 2];
repeat
while ss[i] < x do i := i + 1;
while x < ss[j] do j := j - 1;
if i <= j then
begin
y := ss[i]; ss[i] := ss[j]; ss[j] := y;
i := i + 1; j := j - 1;
end;
until i > j;
if l < j then Sort(l, j);
if i < r then Sort(i, r);
end;
function success:boolean;
var flag:boolean;k:longint;
begin flag:=true;
for k:=1 to n do
if (ss[k]<a)or(ss[k]>b)
then flag:=false;
success:=flag;
end;
begin
assign(f,'groupa.in');
reset(f);
assign(g,'groupa.out');
rewrite(g);
readln(f,n);
for k:=1 to n do
begin read(f,ss[k]);
he:=he+ss[k];
end;
readln(f,a,b);
sort(1,n);
if ((he/n>b) or (he/n<a)) then write(g,'-1') else
begin for k:=1 to n do
begin if ss[k]<a then sum1:=sum1+a-ss[k];
if ss[k]>b then sum2:=sum2+ss[k]-b;
end;
if sum1>sum2 then writeln(g,sum1) else writeln(g,sum2);
end;
close(g);close(f);
end.