Hi Igor!

Before I go in and debut your code, will you please explain the logic behind 
your solution?

> On Apr 9, 2020, at 11:45 AM, Igor Cha <alenwalke...@gmail.com> wrote:
> 
> 
> can anyone help out? D: 
> 
>> On Tuesday, April 7, 2020 at 8:51:58 AM UTC-7, Igor Cha wrote:
>> 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/354c7736-5258-4aad-8e14-cf870e185c9c%40googlegroups.com.

-- 
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/9FE1352E-7BC4-4CE3-9E69-681034E2F28A%40gmail.com.

Reply via email to