[Programmers] 기능 개발

Time Lapse :9min 9sec

solution.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
int day = 0;
int last_day = 0;
vector<int>::iterator it=answer.begin();
for(int i=0;i<progresses.size();i++){
while((progresses[i]+speeds[i]*day)<100){
++day;
}
if(day!=last_day){
answer.push_back(1);
last_day = day;
++it = answer.end()-1;
}
else
++(*it);
}
return answer;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/Programmers/developingFunction/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.