반응형
https://programmers.co.kr/learn/courses/30/lessons/42586
코딩테스트 연습 - 기능개발
프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는
programmers.co.kr
글쓴이의 답
개인적인 풀이 임으로
이것보다 더 좋은 알고리즘은 많음...
이렇게도 풀이하는구나.. 공유하기 위해 올림...
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
vector<int> works;
for(int i=0; i < progresses.size(); i++){
int count =0;
int temp = 100 - progresses[i];
count = temp/speeds[i];
if(0 != temp%speeds[i]){
count++;
}
works.push_back(count);
}
int count=1;
int temp = works[0];
for(int i=1; i<works.size(); i++){
if(temp < works[i]){
answer.push_back(count);
temp = works[i];
count=1;
}
else{
count++;
}
}
if(0 != count){
answer.push_back(count);
}
return answer;
}
꾸준히 하다보면 실력이 늘겠지..
반응형
'코딩테스트' 카테고리의 다른 글
[프로그래머스][C++] 타겟 넘버 (0) | 2022.03.21 |
---|---|
[프로그래머스][C++] 더 맵게 (0) | 2022.03.21 |
[프로그래머스][C++] 124 나라의 숫자 (0) | 2022.03.21 |
[프로그래머스][C++] 멀쩡한 사각형 (0) | 2022.03.20 |
[프로그래머스][C++] 단체사진 찍기 (0) | 2022.03.20 |