Pagini recente » Cod sursa (job #2385357) | Cod sursa (job #572996) | Cod sursa (job #613701) | Cod sursa (job #265269) | Cod sursa (job #76242)
Cod sursa(job #76242)
var i,j,n:longint;
f1,f2:text;
a,b:array[1..1000] of longint;
begin
assign(f1,'harta.in');
reset(f1);
assign(f2,'harta.out');
rewrite(f2);
read(f1,n);
for i:=1 to n do
begin
read(f1,a[i],b[i]);
j:=j+a[i];
end;
writeln(f2,j);
for i:=1 to n do
begin
j:=i+1;
while a[i]>0 do
begin
if (b[j]>0)and(i<>j) then
begin
dec(a[i]);
dec(b[j]);
writeln(f2,i,' ',j);
end;
j:=(j+1) mod n;
if j=0 then j:=n;
end;
end;
for i:=1 to n do
if (a[i]>0)or(b[i]>0) then for j:=1 to maxlongint do writeln(f2);
close(f1);
close(f2);
end.