SHARE
TWEET

Untitled

a guest Oct 16th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top