Do you accept that C and end a job on one minute and start another job on
the same minute?
1
3
1 100
1 50
50 100

?
Paul Smith

p...@pollyandpaul.co.uk


On Tue, 7 Apr 2020 at 01:55, Chandrika Srinivasan <chandasrin...@gmail.com>
wrote:

> Please find the parenting partnering returns code for codejam 2020. It
> fails and shows WA for hidden test cases. But all the known cases are
> passing. Would someone help me in identify what went wrong here ?
>
> Thanks in Advance!
>
> import java.lang.*;
> import java.util.*;
>
> class Activity {
>     private int startMin;
>     private int endMin;
>
>     public Activity(int startMin, int endMin) {
>         this.startMin = startMin;
>         this.endMin = endMin;
>
>         //System.out.println(startMin + " " + endMin);
>     }
>
>     public boolean isValid(Activity activity) {
>        // System.out.println(endMin + " " + activity.getStartMin());
>         /*if(((endMin <= activity.getStartMin()) || (startMin >=
> activity.getEndMin())) && !((startMin == activity.getStartMin()) && (endMin
> == activity.getEndMin()))) {
>             //System.out.println(endMin + " " + activity.getStartMin());
>             return true;
>         } */
>
>         if((endMin <= activity.getStartMin() || activity.getEndMin() <=
> startMin) && !((startMin == activity.getStartMin()) && (endMin ==
> activity.getEndMin()))) {
>
>             return true;
>         }
>
>         return false;
>     }
>
>     public int getStartMin() {
>
>         return startMin;
>     }
>
>     public int getEndMin() {
>         return endMin;
>     }
> }
>
> public class Solution {
>
>     public static void main(String args[]) {
>
>         Scanner in = new Scanner(System.in);
>
>         int n = in.nextInt();
>
>         for(int i = 0; i < n; i++) {
>
>             StringBuilder actvStrb = new StringBuilder();
>
>             int nActv = in.nextInt();
>             ArrayList<Activity> cActivities = new ArrayList<Activity>();
>             ArrayList<Activity> jActivities = new ArrayList<Activity>();
>
>             for(int j = 0; j < nActv; j++) {
>
>                 Activity activity = new Activity(in.nextInt(),
> in.nextInt());
>
>                 boolean impossible = false;
>
>                 if((activity.getStartMin() >= 0) &&
> (activity.getStartMin() < activity.getEndMin()) && (activity.getEndMin() <=
> 24* 60)) {
>
>                     boolean cJob = true;
>                     boolean jJob = true;
>                     for(int c = 0; c < Math.max(cActivities.size(),
> jActivities.size()); c++) {
>
>                         if((c < cActivities.size()) &&
> !cActivities.get(c).isValid(activity)) {
>                             cJob = false;
>                         }
>
>                         if((c < jActivities.size()) &&
> !jActivities.get(c).isValid(activity)) {
>                             jJob = false;
>                         }
>
>                         if(!cJob && !jJob) {
>                             break;
>                         }
>                     }
>
>                     if(cJob) {
>
>                         actvStrb.append("C") ;
>                         cActivities.add(activity);
>                     } else if(jJob) {
>                         actvStrb.append("J");
>                         jActivities.add(activity);
>
>                     } else {
>                           impossible = true;
>                     }
>                 } else {
>                     impossible = true;
>                 }
>
>                 if(impossible) {
>                     //System.out.println(actvStrb.toString());
>                     actvStrb.delete(0, actvStrb.length());
>                     actvStrb.append("IMPOSSIBLE");
>
>                     j++;
>                     while(j < nActv) {
>                         in.nextInt();
>                         in.nextInt();
>                         j++;
>                     }
>
>                     break;
>                 }
>             }
>
>             if(nActv > 0) {
>                 System.out.println("Case #" + (i+1) + ": " +
> actvStrb.toString());
>             }
>         }
>     }
> }
>
> --
> 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/3e93d387-b19e-4cf4-9a02-703f6f53d6f7%40googlegroups.com
> <https://groups.google.com/d/msgid/google-code/3e93d387-b19e-4cf4-9a02-703f6f53d6f7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAJej63KPoosbPHCTkdpK6dkByYF_s3ZvMk93%2BBwmWsVkSPecag%40mail.gmail.com.

Reply via email to