比赛 |
07级noip练习1 |
评测结果 |
AAAAAAAAAA |
题目名称 |
纪念品分组 |
最终得分 |
100 |
用户昵称 |
辨机ZN |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-09-22 21:00:41 |
显示代码纯文本
program ex(f1,f2);
type
zn=array [1..30000] of integer;
var
a:zn; i,j,k,m,n,now,p,ans:longint; max:longint;
f1,f2:text; l,r:longint;
procedure qsort(left,right:longint);
var l,r,x,y:integer;
begin
l:=left; r:=right;
x:=a[(l+r) div 2];
repeat
while a[l]<x do inc(l);
while a[r]>x do dec(r);
if l<=r then
begin
y:=a[l];
a[l]:=a[r];
a[r]:=y;
inc(l);
dec(r);
end;
until l>r;
if l<right then qsort(l,right);
if r>left then qsort(left,r);
end;
begin
assign(f1,'group.in'); assign(f2,'group.out');reset(f1); rewrite(f2);
readln(f1,max);
readln(f1,n);
for i:=1 to n do readln(f1,a[i]);
qsort(1,n);
p:=0; now:=0; ans:=0; ans:=n;
l:=1; r:=n;
while r>=l do
begin
if (a[l]+a[r]<=max)and(l<>r)
then begin
dec(ans);
dec(r);
inc(l);
end
else r:=r-1;
end;
writeln(f2,ans);
close(f1);
close(f2);
end.