Bikes
Submit solution
Points:
10
Time limit:
5.0s
Memory limit:
256M
Author:
Problem type
Allowed languages
C#, Go, Java, Python
Implementa el mètode Race.fastest()
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Bike {
int speed;
public Bike(int speed) {
this.speed = speed;
}
}
class Race {
Bike[] bikes;
// escriu el codi aqui
}
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Race race = new Race();
int numBikes = scanner.nextInt();
race.bikes = new Bike[numBikes];
for (int i = 0; i < numBikes; i++) {
race.bikes[i] = new Bike(scanner.nextInt());
}
Bike fastest = race.fastest();
System.out.println(fastest == null ? "No bikes" : fastest.speed);
}
}
Input Format
-
Constraints
-
Output Format
-
Sample Input 0
3
10 20 30
Sample Output 0
Sample Input 1
4
20 30 20 10
Sample Output 1
Sample Input 2
2
40 30
Sample Output 2
Sample Input 3
Sample Output 3
No bikes
Autoria: Gerard Falcó
CC BY-NC-SA 4.0