Most Fuel Efficient Cars Java Avg 003
Most Fuel Efficient car
Given fuel consumed and the distance covered for a certain number of cars, find the most fuel efficient car.
import java.util.*;
public class Hello {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int[] b=new int[a];
int[] c=new int[a];
int y=0,k=0;
for(int i=0;i<a;i++)
{
b[i]=sc.nextInt();
c[i]=sc.nextInt();
if(y<(c[i]/b[i]))
{
y=c[i]/b[i];
k=i;
}
}
System.out.print(k+1);
}
}
Comments
Post a Comment