Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <string>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. vector<int> solution(vector<int> progresses, vector<int> speeds) {
  7. vector<int> answer;
  8. vector<pair<int, int>> jobs(speeds.size());
  9. for (int i = 0; i < speeds.size(); i++)
  10. jobs[i] = { progresses[i],speeds[i] };
  11. while (!jobs.empty())
  12. {
  13. pair<int, int> t = jobs.front();
  14. if (t.first >= 100)//맨 앞 진도가 100%라면
  15. {
  16. int idx = 0;
  17. while (idx < jobs.size() && jobs[idx].first >= 100)//빠져나가는 갯수를 체크
  18. idx++;
  19. answer.push_back(idx);
  20. jobs.erase(jobs.begin(), jobs.begin() + idx);//범위 삭제
  21. }
  22. else
  23. {
  24. for (int i = 0; i < jobs.size(); i++)
  25. if(jobs[i].first < 100)
  26. jobs[i].first += jobs[i].second;
  27. }
  28. }
  29. return answer;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement