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
- 2단계로킹
- 민겸수
- SQL
- 백준
- 실습
- 오손데이터읽기
- 트랜잭션 관리
- OS
- 언리얼 플러그인
- 1759번
- 백준 1253번
- 데이터베이스 배움터
- 의미와 무의미의 경계에서
- C++
- Unreal
- FBX
- hackerank
- 언리얼 커스텀 플러그인
- oracle
- UnrealMP
- command not found
- Linux
- 1967번
- 셰그먼트트리
- 1253번
- 5639
- Security
- objtofbx
- UActor
- 비재귀셰그먼트
Archives
- Today
- Total
fatalite
C++ 기능개발 [고득점 Kit : 스택 / 큐] 본문
Problem
난이도 : 프로그래머스 2단계
분류 : 큐(deque)
Solution
#include <string>
#include <vector>
#include <deque>
#include <utility>
#include <iostream>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
//length of processes
int length = progresses.size();
deque<pair<int, int>> q;
for(int i=0 ; i < length;i++){
q.push_back({progresses[i], speeds[i]});
}
while(!q.empty()){
int i = 0;
for(int j =0; j < q.size(); j++){
q[j].first += q[j].second;
}
while(q.front().first >= 100){
i++;
q.pop_front();
}
if(i != 0) answer.push_back(i);
}
return answer;
}