회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
[파이썬] 틀렸습니다
20055번 - 컨베이어 벨트 위의 로봇
care9000
3년 전
0
이문제 해결좀 도와주세요 ㅠㅠ
import collections def simulation(): global cnt, result while 1: result += 1 # 1. 회전 belt.appendleft(belt.pop()) cnt_belt.appendleft(cnt_belt.pop()) # 2. 원래 있는 로봇 위치 옮기기 for _ in range(len(robot)): location = robot.popleft() # N 번째 도달하면 내릴것 + 만약 이동 위치 로봇 없고 내구도 0 이아니면 이동 # 이동이 목적지 도달했을 경우 if location + 1 == N : robot_location[N - 1] = 0 pass else: #목적지 아닐경우 if robot_location[location + 1] == 0 and belt[location + 1] != 0 : robot.append(location + 1) belt[location + 1] -= 1 robot_location[location + 1] = 1 robot_location[location] = 0 if belt[location + 1] == 0 and cnt_belt[location + 1] == 0: cnt += 1 cnt_belt[location + 1] += 1 if cnt == K : return else: robot.append(location) # 3. robot 배치 if belt[0] != 0 and robot_location[0] == 0 : robot.append(0) robot_location[0] = 1 if belt[0] == 1 and cnt_belt[0] == 0: cnt += 1 cnt_belt[0] = 1 belt[0] = 0 if cnt == K: return else: belt[0] -= 1 N, K = map(int, input().split()) belt = collections.deque(map(int, input().split())) # 로봇 하나씩 추가 될때마다 앞에서 뺴고 뒤로넣어줄 것 robot = collections.deque() cnt_belt = collections.deque(0 for _ in range(2 * N)) # 로봇 채워지면 1로 표시 robot_location = [0 for _ in range(N)] cnt = 0 result = 0 simulation() print(result)
댓글을 작성하려면
로그인
해야 합니다.
care9000 3년 전
이문제 해결좀 도와주세요 ㅠㅠ