This question which has as its title Colchão
, was initially made available by OBI 2012 and subsequently made available by Uri Online Judge, with the same title, Colchão
, and with the numbering 2409
of the category AD-HOC
.
As you can see, the question asks us to check whether given the dimensions of a mattress, say whether or not it can pass through the door, with one of its faces
, parallel to the floor.
Note that the question says, that the mattress should go through the door with uma
of their faces parallel at the chão
. Also, it tells us that the dimensions of the mattress are (1 <= A, B, C <= 300)
and also, the dimensions of the door are (1 <= H, L <= 250)
.
To resolve this issue correctly we must realize that as the maximum dimension of the mattress is 300
and the maximum door size is 250
and that also, the mattress will always pass through the door with one of its faces paralela
to the ground, we must implement the following algorithm...
colchao = sorted(list(map(int, input().split())))
porta = sorted(list(map(int, input().split())))
if (colchao[0] <= porta[0]) and (colchao[1] <= porta[1]):
print('S')
else:
print('N')
See how the algorithm works on repl it..
Note that when this algorithm is executed, the screen is cleared waiting for the values of dimensões do colchão
. At this point we must, type all the três
dimensions of the mattress, in the mesma
line, separated by apenas um
space and press Enter
.
After we enter all the dimensions of the mattress, the values are ordenados
and stored within the list colchao
.
Then we insert the dimensions of the porta
as we insert the mattress.
After pressing the key enter
the program will check whether the menor
mattress size is less than or equal to menor
dimension of the door and also check whether the dimensão intermediária
of the mattress (width of the mattress) is less than or equal to maior
port size. If the result is positive, it will display the message S
. Otherwise it will display the message N
.
This question has already been testada
, submetida
and properly aprovada
on the website URI
under the programming language Python 3
.
For the record, this issue has only led to 0.036 s to be executed on the URI website.
@Smaug I found myself getting lost at the time of writing, I edited.
– Maniero