Recent Posts
«   2024/12   »
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
Today
Total
관리 메뉴

Try

[Programmers/C++] 기능개발 본문

Algorithm/Programmers

[Programmers/C++] 기능개발

HAS3ONG 2018. 11. 15. 16:49

출처

https://programmers.co.kr/learn/courses/30/lessons/42586



소스



#include <string>

#include <vector>
#include <queue>
#include <iostream>
using namespace std;
vector<int> solution(vector<int> pro, vector<int> spe)
{
vector<int> answer;
queue<int> q;
for(int i = 0; i < pro.size(); i++)
{
int date=0;
while(pro[i] < 100)
{
pro[i]+=spe[i];
date++;
}
q.push(date);
}
while(!q.empty())
{
int fir=q.front();
q.pop();
int n = 0;
int q_cnt=1;
while(n<q.size())
{
int cnt=q.front();
if(fir >= cnt)
{
q.pop();
q_cnt++;
}
else
break;
}
answer.push_back(q_cnt);
}
return answer;
}


'Algorithm > Programmers' 카테고리의 다른 글

[Programmers/C++] 완주하지 못한 선수  (0) 2018.11.18
[Programmers/C++] 124 나라의 숫자  (0) 2018.11.18
[Programmers/C++] 탑  (0) 2018.11.15
[Programmers/C++] 소수의 합  (0) 2018.11.15
[Programmers/C++] 카펫  (0) 2018.11.12
Comments