Question: I was trying to solve this problem: https://open.kattis.com/problems/houselawn I seems to work fine for any test case I can come up with but I get

I was trying to solve this problem:

https://open.kattis.com/problems/houselawn

I seems to work fine for any test case I can come up with but I get wrong aswer upon submission. Any idea what's wrong in my code?

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.ArrayList; public class lawnmower { private static String[] words; private static String[] cand; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); words = in.readLine().split(" "); ArrayList candidates = new ArrayList<>(); int sqm = Integer.parseInt(words[0]); int movers = Integer.parseInt(words[1]); int minprice = 10000000; for (int i = 0; i < movers; i++) { cand = in.readLine().split(","); String name = cand[0]; int price = Integer.parseInt(cand[1]); int cutRate = Integer.parseInt(cand[2]); int cutTime = Integer.parseInt(cand[3]); int chargeTime = Integer.parseInt(cand[4]); //double cutsPrWeek = (10080*52.0 / (cutTime + chargeTime))/52.0; double cutTimeAvg = 0; double cuts = 0; while(cutTimeAvg <10080*2){ for (int j = 0; j < cutTime; j++) { cutTimeAvg++; } cuts++; // System.out.println(cuts); for (int j = 0; j < chargeTime; j++) { cutTimeAvg++; } } double cutsPrWeek = cuts / 2; //System.out.println(cutsPrWeek); // System.out.println(cutsPrWeek); long sqmPrWeek = (long)cutsPrWeek*cutTime*cutRate; if(sqm <= sqmPrWeek){ if(price==minprice) { candidates.add(name); } else if(priceout.println(candidates.get(j)); } } else { System.out.println("no such mower"); } } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!