Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Back tracking
- Data Structure
- Algorithm
- Python
- Trie
- programmers
- django
- SWEA
- boj
- BFS
- SQL
- gpdb
- 모의SW역량테스트
- spring boot
- CSV
- hash table
- Vue.js
- 시뮬레이션
- 알고리듬
- DFS
- aws
- Linked list
- Bruth Force
- 알고리즘
- 코테
- 구현
- 코딩테스트
- Priority Queue
- JavaScript
- GitHub
Archives
- Today
- Total
hotamul의 개발 이야기
[Algorithm][C++] BOJ 20055 컨베이어 벨트 위의 로봇 본문
myt-algorithm-practice/Samsung SW Certi Adv
[Algorithm][C++] BOJ 20055 컨베이어 벨트 위의 로봇
hotamul 2021. 10. 2. 17:30url: https://www.acmicpc.net/problem/20055
20055번: 컨베이어 벨트 위의 로봇
길이가 N인 컨베이어 벨트가 있고, 길이가 2N인 벨트가 이 컨베이어 벨트를 위아래로 감싸며 돌고 있다. 벨트는 길이 1 간격으로 2N개의 칸으로 나뉘어져 있으며, 각 칸에는 아래 그림과 같이 1부
www.acmicpc.net
na982님 풀이 참고
[삼성 SW 역량 테스트] 컨베이어 벨트 위의 로봇
컨베이어 벨트 위의 로봇 강의 컨베이어 벨트 위의 로봇 코드 #include int N, K; int A[200]; int solve() { int ret = 0; int zero_count = 0; int robot[200 * 1000]; int front = 0, back = 0; while (zero_co..
na982.tistory.com
코드
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int n, k;
int map[200];
int solve() {
int ret = 0, zero_cnt = 0;
int robot[200 * 1000];
int fr = 0, re = 0;
while (zero_cnt < k) {
++ret;
int temp = map[2 * n - 1];
for (int i = 2*n - 1; i > 0; i--) {
map[i] = map[i - 1];
}
map[0] = temp;
for (int i = fr; i < re; i++) {
robot[i]++;
if (robot[i] == n - 1) {
fr++;
}
}
for (int i = fr; i < re; i++) {
int next = robot[i] + 1;
if (map[next] == 0 || (i != fr && robot[i - 1] == next)) continue;
robot[i] = next;
if (robot[i] == n - 1) ++fr;
--map[next];
if (map[next] == 0) zero_cnt++;
}
if (map[0] > 0 && (re == 0 || robot[re - 1] != 0)) {
robot[re++] = 0;
--map[0];
if (map[0] == 0) zero_cnt++;
}
}
return ret;
}
int main() {
scanf("%d %d", &n, &k);
for (int i = 0; i < 2*n; i++) {
scanf("%d", &map[i]);
}
int ans = solve();
printf("%d", ans);
return 0;
}
'myt-algorithm-practice > Samsung SW Certi Adv' 카테고리의 다른 글
[Algorithm][C++] BOJ 17825 주사위 윷놀이 (0) | 2021.10.14 |
---|---|
[Algorithm][C++] BOJ 19236 청소년 상어 (0) | 2021.10.04 |
[Algorithm][C++] BOJ 17837 새로운 게임 2 (0) | 2021.09.30 |
[Algorithm][C++] BOJ 17779 게리맨더링2 (0) | 2021.09.29 |
[Algorithm][C++] BOJ 19238 스타트 택시 (0) | 2021.09.29 |
Comments