Pagini recente » Cod sursa (job #2987349) | Cod sursa (job #788089) | Cod sursa (job #1519567) | Cod sursa (job #1508333) | Cod sursa (job #76237)
Cod sursa(job #76237)
var i,j,n,x: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]);
x:=x+a[i];
end;
writeln(f2,x);
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;
close(f1);
close(f2);
end.