문제
https://school.programmers.co.kr/learn/courses/30/lessons/42586
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
코드
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
queue<int>q;
int cnt=0;
int target=100;
for(int i=0;i<speeds.size();i++){
int date=ceil((100-progresses[i])/(double)speeds[i]);
if(i==0)
target=date;
if(target>=date){
cnt++;
}
else{
answer.push_back(cnt);
cnt=1;
target=date;
}
}
answer.push_back(cnt);
return answer;
}
'PS > Programmers' 카테고리의 다른 글
[프로그래머스 Lv.2] 카펫(C++) (0) | 2025.04.03 |
---|---|
[프로그래머스 Lv.1] 같은 숫자는 싫어(C++) (0) | 2025.03.31 |
[프로그래머스 Lv.1] 폰켓몬(C++) (0) | 2025.03.28 |
[프로그래머스 Lv.1] 완주하지 못한 선수(C++) (0) | 2025.03.24 |
[프로그래머스 Lv.2] 서버 증설 횟수(C++) (0) | 2025.03.22 |
댓글