import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
int[] schedules_1 = {700, 800, 1100};
int[][] timelogs_1 = {
{710, 2359, 1050, 700, 650, 631, 659},
{800, 801, 805, 800, 759, 810, 809},
{1105, 1001, 1002, 600, 1059, 1001, 1100}};
int startday_1 = 5;
int[] schedules_2 = {730, 855, 700, 720};
int[][] timelogs_2 = {
{710, 700, 650, 735, 700, 931, 912},
{908, 901, 805, 815, 800, 831, 835},
{705, 701, 702, 705, 710, 710, 711},
{707, 731, 859, 913, 934, 931, 905}};
int startday_2 = 1;
//System.out.print(solution(schedules_1, timelogs_1, startday_1));
System.out.print(solution(schedules_2, timelogs_2, startday_2));
}
public static int solution(int[] schedules, int[][] timelogs, int startday) {
int answer = 0;
for(int i = 0; i < schedules.length; i++) {
boolean check = true;
String str = String.valueOf(schedules[i]);
int hour = 0;
int minute = 0;
if(str.length() == 4) {
hour = Integer.parseInt(str.substring(0,2));
minute = Integer.parseInt(str.substring(2));
}
else {
hour = Integer.parseInt(str.substring(0,1));
minute = Integer.parseInt(str.substring(1));
}
// 10분의 여유 시간
minute += 10;
// 60분 이상 => 1시
hour += minute >= 60 ? 1 : 0;
minute -= minute >= 60 ? 60 : 0;
str = String.valueOf(hour) + (minute == 0 ? "00" : (minute < 10 ? ("0" + minute) : minute));
//System.out.println("\n직원["+(i+1)+"]희망출근시간:"+schedules[i]+"/희망출근시간+10분:"+str);
int toDay = startday;
for(int j = 0; j < 7; j++) {
//String toDay_st = (
// toDay == 1 ? "월" :
// toDay == 2 ? "화" :
// toDay == 3 ? "수" :
// toDay == 4 ? "목" :
// toDay == 5 ? "금" :
// toDay == 6 ? "토" :
// toDay == 7 ? "일" : "Error") +
// "요일";
//System.out.println(
// "출근요일:"+toDay_st+
// " / 희망출근시간/실제출근시간/비교결과:"+str+"/"+timelogs[i][j]+"/"+(Integer.parseInt(str) >= timelogs[i][j] && startday < 6));
if(!(Integer.parseInt(str) >= timelogs[i][j]) && toDay < 6) {
check = false;
//System.out.println("======== [ 실패 ] ========\n");
break;
}
toDay++;
if(toDay > 7)
toDay = 1;
}
if(check)
answer++;
}
//System.out.println("\n========= [ Solution Out] =========\n\n");
return answer;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: