Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. program B;
  2. var
  3. N,K,i,j,max:longint;
  4. a:array[1..200000,1..2] of longint;
  5. begin
  6. max:=-2147483647;
  7. readln(N,K);
  8. for i:=1 to N do
  9. for j:=1 to 2 do
  10. begin
  11. readln(a[i,j]);
  12. end;
  13. for i:=1 to N do
  14. for j:=1 to 2 do
  15. if (a[i,j] > max) then max:=a[i,j];
  16. while (K>0) do
  17. begin
  18. for i:=0 to N do
  19. for j:=0 to 2 do
  20. begin
  21. if (a[i,j] = max) and (a[i+1,j] > a[i,j+1]) then
  22. begin
  23. a[i+1,j]:=1;
  24. a[i,j]:=1;
  25. max:=-2147483647;
  26. end
  27. else if (a[i,j] = max) and (a[i+1,j] < a[i,j+1]) then
  28. begin
  29. a[i,j+1]:=1;
  30. a[i,j]:=1;
  31. max:=-2147483647;
  32. end;
  33. end;
  34. k:=k-1;
  35. end;
  36. for i:=1 to N do
  37. for j:=1 to 2 do
  38. writeln(a[i,j]);
  39. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement