Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type mat=array[0..2001,0..2002] of longint;
- var a:mat;
- i,j,k,n,st,dr,dif,col,p:longint;
- f,g:text;
- begin
- assign(f,'summax1.in');
- assign(g,'summax1.out');
- reset(f);
- rewrite(g);
- read(f,p);
- read(f,n,st,dr);
- for i:=1 to n do begin
- for j:=1 to i do
- read(f,a[i,j]);
- end;
- for j:=1 to n do
- a[j-1,n]:=1;
- for i:=n-1 downto 1 do
- for j:=1 to i do
- if a[i+1,j]>a[i+1,j+1] then
- begin
- a[i,j]:=a[i,j]+a[i+1,j];
- a[j-1,i]:=a[j-1,i+1];
- end
- else
- begin
- a[i,j]:=a[i,j]+a[i+1,j+1];
- a[j-1,i]:=a[j,i+1];
- if a[i+1,j]=a[i+1,j+1] then
- if a[j-1,i]>2000000000-a[j-1,i+1] then
- a[j-1,i]:=2000000001
- else
- a[j-1,i]:=a[j-1,i]+a[j-1,i+1];
- end;
- if p=1 then
- writeln(g,a[0,1]) {a[0,1]}
- else
- begin
- for k:=st to dr do
- begin
- write(g,1);
- dif:=k;
- col:=1;
- for i:=2 to n do
- if (a[col-1,i]>=dif) and (a[i,col]>=a[i,col+1]) then
- begin
- write(g,' ',col);
- end
- else
- begin
- if a[i,col]=a[i,col+1] then
- dif:=dif-a[col-1,i];
- col:=col+1;
- write(g,' ',col);
- end;
- writeln(g);
- end;
- end;
- close(f);
- close(g);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement