Hi, I initially approached this using the same way as in the analysis of the problem, but I thought I found a better solution. However, it kept giving me WA and I am trying to figure out why. It passes all the examples successfully as far as I can tell.
Could someone please help me out? Thanks. The code is below in java. import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int t = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc. for (int i = 1; i <= t; ++i) { int n = in.nextInt(); //schedules for c and j false is free true is busy 0-1440 int[] c = new int[1441]; int[] j = new int[1441]; boolean busyC = false; boolean busyJ = false; boolean impossibleFlag = false; int start = 0; int end = 0; String output = ""; //go through n tasks to try and assign for(int x=1; x<=n; x++){ start = in.nextInt(); end = in.nextInt(); if(!impossibleFlag) { for(int k=start; k<end; k++){ //check schedule for c and j if(c[k]==1){ busyC = true; } if(j[k]==1){ busyJ = true; } } if(!busyC){ output+="C"; //fill C's schedule for(int k=start; k<end; k++){ c[k] = 1; } } else if(!busyJ){ output+="J"; //fill J's schedule for(int k=start; k<end; k++){ j[k] = 1; } } else{ output="IMPOSSIBLE"; impossibleFlag = true; } busyC=false; busyJ=false; } } System.out.println("Case #" + i + ": " + output); } } } -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/ff315652-c34c-4a73-8cde-6b90942296f4%40googlegroups.com.