#include <string>
#include <vector>
/*
1. 직원 수 = schedules.size()
2. schedules[i] = i번째 직원의 출근 희망 시각 (ex: 958 → 9시 58분)
3. timelogs[i][j] = i번째 직원의 이벤트 j+1일차 실제 출근 시각
4. 출근 희망 시각 + 10분 이내에 출근하면 해당 요일 출근 인정
5. 이벤트는 시작 요일 startday부터 7일 동안 진행됨
6. **주말(토/일)**은 인정 대상 제외
7. 일주일 동안 모두 늦지 않게 출근한 직원 수를 구해야 함
*/
using namespace std;
int toMinutes(int time) {
return (time / 100) * 60 + (time % 100);
}
int solution(vector<int> schedules, vector<vector<int>> timelogs, int startday) {
int answer = 0;
int n = schedules.size();
for (int i = 0; i < n; ++i) {
bool onTimeAllWeek = true;
for (int day = 0; day < 7; ++day) {
int currentDayOfWeek = (startday - 1 + day) % 7 + 1; //시작 요일이 언제든 요일 계산을 % 7로 처리해야 합니다.
// 주말은 체크하지 않음
if (currentDayOfWeek == 6 || currentDayOfWeek == 7) continue;
int scheduled = toMinutes(schedules[i]);
int deadline = scheduled + 10;
int actual = toMinutes(timelogs[i][day]); //timelogs[i][day]는 항상 7일치가 들어오므로 인덱스는 그대로 0~6 사용 가능합니다.
if (actual > deadline) {
onTimeAllWeek = false;
break;
}
}
if (onTimeAllWeek) {
++answer;
}
}
return answer;
}