比赛 10.10.18noip模拟 评测结果 AAAAAAWWWA
题目名称 罪犯问题A 最终得分 70
用户昵称 ZhouZn1 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-10-18 19:35:43
显示代码纯文本
program zzn;
var
        i,j,m,n,max,min:longint;
        peo:array[1..50000]of integer;
        num:array[1..1000]of boolean;
procedure init;
begin
        assign(input,'criminala.in');
        reset(input);
        assign(output,'criminala.out');
        rewrite(output);
        readln(n,m);
        for i:=1 to m do
         begin
             readln(peo[i]);
         end;
       min:=maxlongint;
       max:=-1;
end;
procedure work;
var
        i,x:integer;
begin
        x:=0;
        for i:=1 to m do
         if  peo[i]<0 then
          begin
              if num[abs(peo[i])] then  inc(x);
          end else
          begin
             if not(num[peo[i]]) then inc(x);
          end;
        if x>max then max:=x;
        if x<min then min:=x;
end;
procedure dep(x:integer);
begin
    if x>n then
     begin
         work;
         exit;
     end;
    num[x]:=true;
    dep(x+1);
    num[x]:=false;
    dep(x+1);

end;
procedure main;
begin
        fillchar(num,sizeof(num),0);
        dep(1);
        writeln(max);
        writeln(min);
end;
procedure closef;
begin
        close(input);
        close(output);
end;
function max2(a,b:integer):integer;
begin
    if a>b then exit(a) else exit(b);
end;
function min2(a,b:integer):integer;
begin
    if a<b then exit(a) else exit(b);
end;
procedure main2;
var
        i,j,x,y,s1,s2:integer;
begin
        s1:=0;s2:=0;
        for i:=1 to n do
        begin
        x:=0;y:=0;
         for j:=1 to m do
         begin
          if (peo[j]<0)and(abs(peo[j])=i) then inc(x);
          if (peo[j]>0)and(peo[j]=i) then inc(y);
         end;
        inc(s1,max2(x,y));inc(s2,min2(x,y));
        end;
        writeln(s1);
        writeln(s2);
end;
begin
        init;
        if n<=10 then
        main else
        main2;
        closef;
end.