https://programmers.co.kr/learn/courses/30/lessons/42586
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
int size = progresses.size();
vector<int> answer;
vector<int> day(size);
for(int i=0;i<size;i++){
int rest = 100-progresses[i];
if(rest < speeds[i])
day[i]= 1;
else{
if(rest%speeds[i] == 0)
day[i] = rest/speeds[i];
else
day[i] = rest/speeds[i] + 1;
}
}
int count = -1;
int num = -1;
for(int i=0;i<size;i++){
if(num >= day[i])
answer[count]++;
else{
answer.push_back(1);
num = day[i];
count++;
}
}
return answer;
}
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
int day;
int max_day = 0;
for (int i = 0; i < progresses.size(); ++i)
{
day = (99 - progresses[i]) / speeds[i] + 1;
if (answer.empty() || max_day < day)
answer.push_back(1);
else
++answer.back();
if (max_day < day)
max_day = day;
}
return answer;
}