#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
// 전체 시간으로 각 작업들의 속도와 비교할수 있다.
int time = 0;
int res = 0;
for(int i=0; i<progresses.size(); i++){
// 작업이 100이 넘었는지 아닌지를 체크함
// 만약 넘었을 경우 res를 증가시킴
if(progresses[i]+time*speeds[i] >= 100){
res++;
}
else{
if(i != 0){
printf("%d %d %d\n",time,res, i);
// 이후 res값을 answer에 넣음. 즉 작업 완료된 개수를 넣기
answer.push_back(res);
res = 0;
}
// 다음 작업이 완료될때까지 시간을 늘림
while(progresses[i]+time*speeds[i] < 100){
time++;
}
// 작업 하나가 완료되었으므로 res++을 해줌.
res++;
}
}
if(res != 0) answer.push_back(res);
return answer;
}
큐를 사용하지 않고, 문제를 해결한 것. 사실 단순한 문제였으므로 그냥 한번 쭉 읽어만 보자.