
https://school.programmers.co.kr/learn/courses/30/lessons/388351
프로그래머스
SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
시간이라는 조건을 이용하는 간단한 문제입니다.
문제 조건에 직원이 출근하지 않는 날이 있을 수 있다는 언급이 없으며
schedules[i]자체가 1100보다 작기 때문에 날짜가 넘어갈 일이 없습니다.
일반적으로 하는 시간 낚시가 없기 때문에 50 + 10 = 110같은 기본적인 시간 연산만 신경쓰면 쉽게 통과할 수 있습니다.
#include <string>
#include <vector>
using namespace std;
int solution(vector<int> schedules, vector<vector<int>> timelogs, int startday) {
int N = schedules.size();
int answer = N;
int days = timelogs[0].size();
--startday;
for (int i = 0; i < N; ++i)
{
int hour = schedules[i] / 100;
int minutes = schedules[i] - 100 * hour;
minutes += 10;
if (minutes >= 60)
{
++hour;
minutes -= 60;
}
schedules[i] = hour * 100 + minutes;
}
for (int i = 0; i < N; ++i)
{
for (int d = 0; d < days; ++d)
{
int curday = (startday + d) % 7;
if (curday == 5 || curday == 6)
continue;
if (schedules[i] < timelogs[i][d])
{
--answer;
break;
}
}
}
return answer;
}'Algorithm > PS' 카테고리의 다른 글
| [1일 1알고] 택배 상자 꺼내기 (0) | 2026.04.30 |
|---|---|
| [1일 1알고] [PCCP 기출문제] 4번 / 수식 복원하기 (0) | 2026.04.29 |
| [1일 1알고] 완전 범죄 (0) | 2026.04.22 |
| [1일 1알고] 서버 증설 횟수 (0) | 2026.04.21 |
| [1일 1알고] 노란불 신호등 (1) | 2026.04.21 |