プリンタ
プログラマプリンタの問題
https://programmers.co.kr/learn/courses/30/lessons/42587![ ]
https://programmers.co.kr/learn/courses/30/lessons/42587![ ]
#include <string>
#include <vector>
#include <queue>
using namespace std;
int solution(vector<int> priorities, int location) {
int answer = 0;
priority_queue<int> q;
queue<pair<int, int>> abc;
for (int i = 0; i < priorities.size(); i++) {
abc.push({ i,priorities[i] });
q.push(priorities[i]);
}
while (!abc.empty()) {
int a = abc.front().first; //가장앞에있는 문서
int b = abc.front().second; // 가장앞의 중요도
abc.pop();
if (q.top() == b) { //가장 높은 중요도일때,
q.pop();
answer += 1; //1회증가
if (location == a) { //찾고자하는 순서
break;
}
}
else {
abc.push({ a,b }); //뒤로
}
}
return answer;
}
int main() {
vector<int> a = { 2,1,3,2 };
solution(a, 2);
return 0;
}
Reference
この問題について(プリンタ), 我々は、より多くの情報をここで見つけました https://velog.io/@trevor522/프린터テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol