반응형
- 문제
프로그레스와 속도가 주어질 때 가장 앞에 있는 프로그래스가 완료될 때 같이 완료되는 프로그래스의 수를 출력하는 문제다.
- 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
int max;
int once = 0;
vector<int> times(progresses.size(),0);
for(int i = 0; i < progresses.size(); i++){
times[i] = (100-progresses[i] - 1)/speeds[i]+1;
}
times.push_back(101);
max = times[0];
for(int i = 0; i < times.size(); i++){
if( max < times[i] || i == times.size()-1){
max = times[i];
answer.push_back(once);
once = 1;
}
else{
once++;
}
}
return answer;
}
딱히 설명할 게 없는 문제다.
- 기억할 것!
X
반응형
'Algorithm > 프로그래머스' 카테고리의 다른 글
프로그래머스 프린터 C++ (0) | 2022.10.22 |
---|---|
프로그래머스 [1차] 뉴스 클러스터링 (0) | 2022.10.22 |
프로그래머스 위장 C++ (0) | 2022.10.22 |
프로그래머스 n^2 배열 자르기 C++ (2) | 2022.10.22 |
프로그래머스 튜플 C++ (0) | 2022.10.22 |