Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- broadcastreceiver
- 두 동전
- Android
- 17837
- data
- 단축키
- Algorithm
- IntelliJ
- activity
- github
- git
- spring
- 백준
- intent
- goland
- Java
- vscode
- 프로그래머스
- 알고리즘
- 데이터전달
- 데이터
- insert
- 안드로이드
- 16197
- 큐빙
- 제어반전
- service
- mysql
- Jenknis
- ubuntu
Archives
- Today
- Total
해보자
프로그래머스_LV2_프린터 본문
https://programmers.co.kr/learn/courses/30/lessons/42587?language=cpp
코딩테스트 연습 - 프린터 | 프로그래머스
일반적인 프린터는 인쇄 요청이 들어온 순서대로 인쇄합니다. 그렇기 때문에 중요한 문서가 나중에 인쇄될 수 있습니다. 이런 문제를 보완하기 위해 중요도가 높은 문서를 먼저 인쇄하는 프린터를 개발했습니다. 이 새롭게 개발한 프린터는 아래와 같은 방식으로 인쇄 작업을 수행합니다. 1. 인쇄 대기목록의 가장 앞에 있는 문서(J)를 대기목록에서 꺼냅니다. 2. 나머지 인쇄 대기목록에서 J보다 중요도가 높은 문서가 한 개라도 존재하면 J를 대기목록의 가장 마지막에
programmers.co.kr

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <vector> #include <string> #include <deque> using namespace std; int solution(vector<int> priorities, int location) { int answer = 0; deque<pair<int, int>> dq; for ( int i=0; i < priorities.size(); i++) { dq.push_back(make_pair(i, priorities[i])); } while (!dq.empty()) { pair<int, int> temp = make_pair(dq.front().first, dq.front().second); bool bigPriority = false; for(int i = 0; i < dq.size(); i++) { if (temp.second < dq[i].second) { bigPriority = true; dq.pop_front(); dq.push_back(temp); break; } } if (!bigPriority) { dq.pop_front(); answer++; if (temp.first == location) { return answer; } } } return answer; } | cs |
'C++ > Solve & Think' 카테고리의 다른 글
프로그래머스_LV2_다리를 지나는 트럭 (0) | 2020.02.26 |
---|---|
프로그래머스_LV2_기능개발 (0) | 2020.02.21 |
백준_7576번_토마토 (0) | 2020.02.20 |
백준_10610번_30 (0) | 2020.02.12 |
백준_1966번_프린터 큐 (0) | 2019.12.18 |