[프로그래머스/C++] 기능개발

mani·2023년 4월 13일
0
post-custom-banner

기능개발

엄청나다

#include <string>
#include <vector>

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;
}
```cpp
#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> progresses, vector<int> speeds) {
    vector<int> answer;
    
    vector<int> pg_now(progresses.begin(), progresses.end());
    int now = 0;
    
    while(1){
        for(int i=0;i<progresses.size();i++){
            if(pg_now[i]<100)
                pg_now[i] += speeds[i];
        }
        
        if(pg_now[now]>=100){
            int num = 1;
            now++;
            
            if(now==progresses.size()){
                answer.push_back(num);
                return answer;
            }
            
            while(pg_now[now]>=100){
                num++;
                now++;
                if(now==progresses.size()){
                    answer.push_back(num);
                    return answer;
                }
            }
            answer.push_back(num);
        }
    }
    
    return answer;
}
profile
log
post-custom-banner

0개의 댓글