记录编号 111726 评测结果 AAAAAAAAAA
题目名称 [USACO 2.1] 荷斯坦奶牛 最终得分 100
用户昵称 GravatarFoolMike 是否通过 通过
代码语言 Pascal 运行时间 0.011 s
提交时间 2014-07-14 08:03:56 内存使用 0.17 MiB
显示代码纯文本
var
a,b,v,g,ans:longint;
v1,d:array[1..25]of longint;
g1:array[1..15,1..25]of longint;
g2:array[1..15]of longint;

procedure siliao(w,s:longint);
var
i,j:longint;
begin
if ans=1 then exit;
if s=a then
  begin
  j:=0;
  for i:=1 to v do
  if not(d[i]>=v1[i]) then
    begin
    j:=1;break;
    end;
  if j=0 then
    begin
    ans:=1;
    write(a,' ');
    for i:=1 to g do
    if g2[i]=1 then write(i,' ');
    writeln;
    end;
  end;

if s<>a then
for i:=w+1 to g-(a-s)+1 do
if g2[i]=0 then
  begin
  for j:=1 to v do
  d[j]:=d[j]+g1[i,j];
  g2[i]:=1;
  siliao(i,s+1);
  g2[i]:=0;
  for j:=1 to v do
  d[j]:=d[j]-g1[i,j];
  end;
end;

begin
assign(input,'holstein.in');
assign(output,'holstein.out');
reset(input);
rewrite(output);

readln(v);
for a:=1 to v do
read(v1[a]);
readln(g);
for a:=1 to g do
for b:=1 to v do
read(g1[a,b]);

ans:=0;
for a:=1 to g do
  begin
  siliao(0,0);
  if ans=1 then break;
  end;
close(input);close(output);
end.