记录编号 |
22337 |
评测结果 |
AAAAAAAWWA |
题目名称 |
分班 |
最终得分 |
80 |
用户昵称 |
sr-end |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.000 s |
提交时间 |
2010-11-18 16:56:11 |
内存使用 |
0.11 MiB |
显示代码纯文本
program aa;
var
head,tail,x:integer;
a:array[1..100] of integer;
f,f1:text;
k:real;
n,l,r,s,v,sort,p,q:integer;
i,j:integer;
function zai(b:integer):boolean;
begin
if (b<=r)and(b>=l) then zai:=true
else zai:=false;
end;
begin
k:=0;
s:=0;
assign(f,'groupa.in'); assign(f1,'groupa.out');
reset(f);
rewrite(f1);
readln(f,n);
for i:=1 to n do
read(f,a[i]);
readln(f);
read(f,l,r);
for i:=1 to n do
k:=k+a[i];
if (k/n<l) or (k/n>r) then
begin
write(f1,'-1');
end
else
begin
for i:=1 to n do
begin
if a[i]<l then p:=p+l-a[i];
if a[i]>r then q:=q+a[i]-r
end;
if p>q then write(f1,p) else write(f1,q);
{for i:=1 to n do
if zai(a[i]) then inc(s);
if s=n then
begin
write(f1,0);
end
else
begin
for i:=1 to n do
for j:=i to n do
if a[i]<a[j] then begin
sort:=a[i];
a[i]:=a[j];
a[j]:=sort;
end;
head:=1;
tail:=n;
repeat
repeat
if (a[head]>l)or (a[tail]<l) then
begin
dec(a[head]);
inc(a[tail]);
x:=x+1;
end;
until
(a[head]>=l) or (a[tail]>=l);
if a[head]<=l then inc(head);
if a[tail]>=l then dec(tail);
until
head=tail;
v:=a[head]-r;
write(f1,x+v); }
end;
close(f);close(f1);
end.