First, solve the problem. Then, write the code. ” - John Johnson

It's not at all important to get it right the first time. It's vitally important to get it right the last time. ” - Andrew Hunt and David Thomas

Sunday, July 20, 2014

Falling Ants.

Author : Jisan
Programming language : Java 
Difficulty : Easy
Status : Accepted
Problem number : UVA-12709
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4447

Code:

import java.util.*;
public class Uva_12709 {

public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int sum=0;
int sum1=0;
while(in.hasNext()){
int a=in.nextInt();
if(a==0){
break;
}
int max=-6;
 for(int i=1;i<=a;i++){
int L=in.nextInt();
int W=in.nextInt();
int H=in.nextInt();
if(H>=max)
{
sum = L * W * H;
if(max == H)
{
if(sum>sum1)
{
sum1 = sum;
}
}
if(H>max)
{
max = H;
sum1 = sum;
}
}
}
System.out.println(sum1);
}
}
}

No comments:

Post a Comment