Algorithm
Problem Name: 2 AD-HOC - beecrowd | 2175
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2175
What is the Fastest?
By Jadson José Monteiro Oliveira, Faculdade de Balsas Brazil
Timelimit: 1
Otavio, Bruno and Ian are childhood friends, passionate about challenges and water sports. In Olympic times they challenge each other, simulating some competitions such as swimming. The problem is that swimming, for example, they train enough together and sometimes the time difference between them is very short, due to this, in most cases they are hours and hours discussing who won. Now they decided to invest in the development of electronic equipment to be used specifically in swimming, which identifies the time that each swam and displays who was the fastest. You're part of the team that will develop the equipment and your task in the project is to create a program to receive the time of 3 friends and say who was the winner.
Input
Each test case consists of a single line containing three numbers, separated by a blank space, O (0 ≤ O ≤ 100), B (0 ≤ B ≤ 100) and I (0 ≤ I ≤ 100), representing respectively the time in seconds of Otavio, Bruno and Ian. Times will have a maximum of 3 decimal places.
Output
For each test case, your program must print a single line containing the name of the winning competitor, the fastest. If there is a tie and you can not determine a single winner, you should print the word "Empate" (it means tie in Portuguese) without quotes.
Input Sample | Output Sample |
10 20 30 |
Otavio |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main (void)
{
float otavio, bruno, ian;
scanf("%f %f %f", &otavio, &bruno, &ian);
if (otavio < bruno && otavio < ian)
printf("Otavio\n");
else if (bruno < otavio && bruno < ian)
printf("Bruno\n");
else if (ian < otavio && ian < bruno)
printf("Ian\n");
else
printf("Empate\n");
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main() {
double otavio, bruno, flavio;
scanf("%lf %lf %lf", &otavio, &bruno, &flavio);
if (otavio < bruno && otavio < flavio)
printf("Otavio\n");
else if (bruno < otavio && bruno < flavio)
printf("Bruno\n");
else if (flavio < otavio && flavio < bruno)
printf("Ian\n");
else
printf("Empate\n");
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Python Programming
Code -
Python Programming
e = [float(x) for x in str(input()).split()]
if sorted(e)[0] == sorted(e)[1]: print('Empate')
else:
if e.index(min(e)) == 0: print('Otavio')
elif e.index(min(e)) == 1: print('Bruno')
else: print('Ian')
Copy The Code &
Try With Live Editor
Input
Output