比赛 |
20101118 |
评测结果 |
AAAAAAAAAA |
题目名称 |
分班 |
最终得分 |
100 |
用户昵称 |
1102 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-18 08:48:06 |
显示代码纯文本
program xxxx;
var a:array[1..50000,0..2] of longint;
i,n,w,x,y,r,l:longint;
function max(a1,a2:longint):longint;
begin
if a1>a2 then
max:=a1
else
max:=a2;
end;
begin
assign(input,'groupa.in');
reset(input);
assign(output,'groupa.out');
rewrite(output);
read(n);
for i:=1 to n do
begin
read(a[i,0]);
w:=w+a[i,0];
end;
read(l,r);
if (l*n>w)or(r*n<w) then
begin
write('-1');
close(input);
close(output);
halt;
end;
for i:=1 to n do
begin
if a[i,0]<l then
a[i,1]:=l-a[i,0]
else
a[i,1]:=0;
if a[i,0]>r then
a[i,2]:=a[i,0]-r
else
a[i,2]:=0;
end;
x:=0;
y:=0;
for i:=1 to n do
begin
x:=x+a[i,1];
y:=y+a[i,2];
end;
x:=max(x,y);
write(x);
close(input);
close(output);
end.