You are viewing a single comment's thread. Return to all comments →
Constant time procedure using Java:
public static void main(String[] args) { Scanner input = new Scanner(System.in); Queue <Integer> myQueue = new LinkedList<Integer>(); for (int i = 0; i < 3; i++) { myQueue.add(input.nextInt()); } int dif1 = myQueue.remove() - input.nextInt(); int dif2 = myQueue.remove() - input.nextInt(); int dif3 = myQueue.remove() - input.nextInt(); if ((dif1 <= 0 && dif2 <= 0 && dif3 <= 0) || (dif1 > 0 && (dif2 < 0 || dif3 < 0))) System.out.println(0); else if (dif1 > 0 && dif2 == 0 && dif3 == 0) System.out.println(15*dif1); else if (dif2 > 0 && dif3 == 0) System.out.println(500*dif2); else System.out.println(10000); }
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Logic
You are viewing a single comment's thread. Return to all comments →
Constant time procedure using Java: