比赛 20140714上午练习 评测结果 AAAAAAAAAA
题目名称 荷斯坦奶牛 最终得分 100
用户昵称 农场主 运行时间 0.084 s
代码语言 Pascal 内存使用 0.17 MiB
提交时间 2014-07-14 11:09:59
显示代码纯文本
    program zht;
    var
    v,g,i,j,b,k,zk,zhh,hh:integer;
    x:array[1..25] of longint;
    z:array[1..15,1..25] of longint;
    zh,c,h,hz:array[1..30] of longint;
    begin
    assign(input,'holstein.in');
    assign(output,'holstein.out');
    reset(input);
    rewrite(output);
    readln(v);
    for i:=1 to v do
    read(x[i]);
    readln(g);
    for i:=1 to g do
    begin
    for j:=1 to v do
    read(z[i,j]);
    end;
    zk:=500;
    while c[g+1]<>1 do
    begin
    b:=0;
    k:=0;
    hh:=0;
    for i:=1 to g do
    zh[i]:=0;
    c[1]:=c[1]+1;
    for i:=1 to g do
    if c[i]=2 then begin c[i]:=0;c[i+1]:=c[i+1]+1;end;
    if c[g+1]=1 then break;
    for i:=1 to v do
    h[i]:=0;
    for i:=1 to g do
    if c[i]=1 then begin for j:=1 to v do h[j]:=h[j]+z[i,j];inc(k);zh[k]:=i;end;
    for i:=1 to v do
    begin
    if h[i]<x[i] then b:=1;

    end;
    if b=0 then if k<zk then begin zk:=k;for i:=1 to g do hz[i]:=zh[i]; end
    else if k=zk then for i:=1 to g do if zh[i]<hz[i] then hh:=1;
    if hh=1 then for i:=1 to g do hz[i]:=zh[i];
    end;
    write(zk,' ');
    for i:=1 to zk do
    write(hz[i],' ');
    close(input);
    close(output);
    end.