Part of the problem is to interpret the phrase
"distance of this straight line is maximum from origin".
I interpret this to mean that we must choose a line $AB$ that maximizes
the distance from the origin to the line,
given that the line must pass through $(3,1)$.
Fact 1: The distance from a point to a straight line is the distance from the given point to whatever point on the straight line is closest to the given point.
What point on the line $AB$ is closest to the origin?
Hint: the closest point cannot be farther than $(3,1)$, since $(3,1)$ is on $AB$; and we want to maximize the distance to the line, so we want the
"closest point" to be as far from the origin as it can be.
Fact 2: The line from a given point to the closest point on a given line is
perpendicular to the line.
Find the slope of the line from the origin to the closest point on
line $AB$. Now find the slope of the perpendicular line.
At this point you should have the slope of the line $AB$ and one point
on the line, which is enough to get the equation of the line,
from which you can find the coordinates of $A$ and $B$ on the axes
and you have the dimensions of the triangle.