Created
October 30, 2012 19:45
-
-
Save SudhagarS/3982539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class Schedule { | |
public static void main(String args[]) throws IOException{ | |
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | |
StringTokenizer st=new StringTokenizer(br.readLine()); | |
boolean m[]=new boolean[1441];m[1440]=false; | |
int n=Integer.parseInt(st.nextToken());int meeting_time=Integer.parseInt(st.nextToken()),shh,smm,ehh,emm,ashh=0,asmm=0,aehh=0,aemm=0; | |
while(n--!=0){ | |
st=new StringTokenizer(br.readLine()); | |
shh=Integer.parseInt(st.nextToken());smm=Integer.parseInt(st.nextToken());ehh=Integer.parseInt(st.nextToken());emm=Integer.parseInt(st.nextToken()); | |
if(emm==0){emm=59;ehh-=1;} | |
else emm--; | |
for(int i=shh*60+smm;i<=ehh*60+emm;i++){ | |
m[i]=true; | |
} | |
} | |
int curr_run=0,flag=0;; | |
for(int i=0;i<=1440;i++){ | |
if(m[i]==false) { | |
if(curr_run==0){ | |
asmm=i%60; | |
ashh=(i-asmm)/60; | |
} | |
curr_run++; | |
} | |
else { | |
if(curr_run>=meeting_time){ | |
aemm=i%60; | |
aehh=(i-aemm)/60; | |
System.out.format("%02d %02d %02d %02d\n",ashh,asmm,aehh,aemm); | |
} | |
curr_run=0; | |
} | |
} | |
if(curr_run>=meeting_time){ | |
aemm=00; | |
aehh=00; | |
System.out.format("%02d %02d %02d %02d\n",ashh,asmm,aehh,aemm); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment