排序,从小到大,看看小的和大的最多组成的个数。var n:longint; a:array[1..30000] of longint;PRocedure qsort(l,r:longint);var i,j,key,temp:longint;begin if l>=r then exit; i:=l;j:=r; key:=a[l+random(r-l+1)]; repeat while (a[i]<key) do inc(i); while (a[j]>key) do dec(j); if i<=j then begin temp:=a[i];a[i]:=a[j];a[j]:=temp; inc(i);dec(j); end; until i>j; qsort(l,j); qsort(i,r);end;var i,j,m,p:longint;begin readln(m); readln(n); for i:=1 to n do readln(a[i]); randomize; qsort(1,n); j:=n;i:=1; while i<=j do if a[i]+a[j]<=m then begin inc(i);inc(p);dec(j);end else if a[j]<=m then begin dec(j);inc(p);end else dec(j); writeln(p);end.