프로그래머스(C++) - 기능개발

2025. 8. 7. 20:09·C++ 프로그래머스 다이어리/Stack,Queue

●문제

 

●입출력

 

사용 알고리즘 : Stack

#include <string>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

vector<int> solution(vector<int> progresses, vector<int> speeds) 
{
    vector<int> answer;
    vector<int> stkDay;
    for (int i = 0; i < progresses.size(); i++)
    {
        int leftDay = (100 - progresses[i] + speeds[i] - 1) / speeds[i];
        stkDay.push_back(leftDay);
    }
    int current = stkDay[0];
    int count = 1;
    for (int i = 1; i < stkDay.size(); i++)
    {
        //한번에 배포해주는 경우 계산
        if (stkDay[i] <= current)
        {
            count++;
        }
        else
        {
            answer.push_back(count);
            current = stkDay[i];
            count = 1;
        }
    }
    answer.push_back(count);
    return answer;

}

 

레벨 : 2

점수 : 1

'C++ 프로그래머스 다이어리 > Stack,Queue' 카테고리의 다른 글

프로그래머스(C++) - 괄호 회전하기  (0) 2025.10.14
프로그래머스(C++) - 주식가격  (0) 2025.10.08
프로그래머스(C++) - 프로세스  (0) 2025.10.08
Algorithm - Stack, Queue  (0) 2025.08.07
프로그래머스(C++) - 짝지어 제거하기  (0) 2025.08.02
'C++ 프로그래머스 다이어리/Stack,Queue' 카테고리의 다른 글
  • 프로그래머스(C++) - 주식가격
  • 프로그래머스(C++) - 프로세스
  • Algorithm - Stack, Queue
  • 프로그래머스(C++) - 짝지어 제거하기
lucodev
lucodev
커피와 노트북 그리고 개발
  • lucodev
    루코 개발테이블
    lucodev
  • 전체
    오늘
    어제
    • 분류 전체보기 (171) N
      • Unreal5 프로젝트 다이어리 (73)
      • Unreal5 프로젝트 다이어리2 (11)
      • Unreal 팁 (8)
      • Unreal 디버깅 (8)
      • 코드 개인보관함 (8)
      • C++ 프로그래머스 다이어리 (49) N
        • Stack,Queue (6)
        • Hash (4)
        • Heap (2)
        • Sort (5)
        • Exhaustive search (5)
        • Greedy (2)
        • BFS , DFS (6)
        • Graph (2)
        • Dynamic Programming (1)
        • C++ Math (2)
        • 기타 문제 (13) N
      • 코딩테스트+@ (10) N
      • 알고리즘 스타디 (1)
      • 알고리즘 스타디 과제 (3)
  • 인기 글

  • 최근 글

  • 최근 댓글

  • 링크

  • 공지사항

  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 태그

    unreal 로딩
    언리얼 motionmatching
    언리얼 look at
    언리얼 로딩
    언리얼 behavior tree
    언리얼 컷씬
    언리얼 behaviortree
    언리얼 비헤이비어트리
    unreal 모션매칭
    언리얼 모션매칭
    unreal 컷씬
    언리얼 페이드 아웃
    언리얼
    unreal loading
    unreal sequence
    언리얼 foot step
    unreal 시퀀스
    언리얼 시퀀스
    언리얼 로딩창
    unreal look at
  • hELLO· Designed By정상우.v4.10.3
lucodev
프로그래머스(C++) - 기능개발
상단으로

티스토리툴바