Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 문자열
- 삼성SW테스트
- 레벨3
- dfs
- KAKAO
- 완전탐색
- C++
- 시뮬레이션
- 백준
- 2018
- STL
- 프로그래머스
- 백트래킹
- swea
- substr
- 레벨2
- 코딩스킬
- 삼성
- priority_queue
- BFS
- 삼성SW역량테스트
- 코딩테스트
- dp
- 브루트포스
- Sort
- Map
- 모의SW역량테스트
- find
- 이런게4문제
- Set
Archives
- Today
- Total
-
[프로그래머스] 레벨 2 - 기능개발 본문
https://programmers.co.kr/learn/courses/30/lessons/42586?language=cpp
코딩테스트 연습 - 기능개발 | 프로그래머스
프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 기능보다 먼저 개발될 수 있고, 이때 뒤에 있는 기능은 앞에 있는 기능이 배포될 때 함께 배포됩니다. 먼저 배포되어야 하는 순서대로 작업의 진도가 적힌 정수 배열 progresses와 각 작업의 개발 속도가 적힌 정수 배열 speeds가 주어질 때 각 배포마다 몇
programmers.co.kr
루프를 한 번만 돌면서 풀 수 있는 문제는 가급적 여러번 for문 쓰지 말고 바로 풀자.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
vector<int> remain;
for(int i=0; i<progresses.size(); i++){
if(((100 - progresses[i]) % speeds[i]) == 0){
remain.push_back((100 - progresses[i]) / speeds[i]);
}
else{
remain.push_back((100 - progresses[i]) / speeds[i] + 1);
}
}
// 7, 3, 9
int cur = remain[0];
int cnt = 1;
for(int i=1; i<remain.size(); i++){
if(cur < remain[i]){
answer.push_back(cnt);
cnt = 1;
cur = remain[i];
}
else{
cnt++;
}
if(i==remain.size()-1)
answer.push_back(cnt);
}
return answer;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'1-4. 프로그래머스' 카테고리의 다른 글
[프로그래머스] 레벨 2 - 주식가격 (0) | 2020.02.04 |
---|---|
[프로그래머스] 레벨 2 - 다리를 지나는 트럭 (0) | 2020.02.03 |
[프로그래머스] 레벨 2 - 프린터 (0) | 2020.02.03 |
[프로그래머스] 레벨 2 - 탑 (0) | 2020.02.03 |
[프로그래머스] 레벨 2 - 카카오프렌즈 컬러링북 (2017 카카오코드 예선) (0) | 2020.02.03 |
Comments