Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program B;
- var
- N,K,i,j,max:longint;
- a:array[1..200000,1..2] of longint;
- begin
- max:=-2147483647;
- readln(N,K);
- for i:=1 to N do
- for j:=1 to 2 do
- begin
- readln(a[i,j]);
- end;
- for i:=1 to N do
- for j:=1 to 2 do
- if (a[i,j] > max) then max:=a[i,j];
- while (K>0) do
- begin
- for i:=0 to N do
- for j:=0 to 2 do
- begin
- if (a[i,j] = max) and (a[i+1,j] > a[i,j+1]) then
- begin
- a[i+1,j]:=1;
- a[i,j]:=1;
- max:=-2147483647;
- end
- else if (a[i,j] = max) and (a[i+1,j] < a[i,j+1]) then
- begin
- a[i,j+1]:=1;
- a[i,j]:=1;
- max:=-2147483647;
- end;
- end;
- k:=k-1;
- end;
- for i:=1 to N do
- for j:=1 to 2 do
- writeln(a[i,j]);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement