프린터
-
[프로그래머스] 프린터알고리즘/프로그래머스 2021. 7. 19. 14:42
문제 링크 풀이 이 문제는 크게 두 가지 방법으로 풀 수 있는 것 같습니다. 효율성이나 성능을 고려했을 때 반복문을 줄이는 게 좋다고 생각합니다. 이 관점에서, 우선순위 큐를 사용하면 알고리즘 헤더의 max_element를 매번 사용하지 않아도 되기 때문에 빠르고 효율이 좋습니다. pair을 연습해볼 수도 있어서 좋습니다. 코드1 #include #include #include using namespace std; int solution(vector priorities, int location) { int answer = 1; queue index_value_q; priority_queue pq; for (int i = 0; i < priorities.size(); ++i) { index_value_q...