250x250
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 |
Tags
- 4948
- end to end
- Python
- Retrieval
- 경사하강법
- 손실함수
- 기계학습
- N-Queen
- 재귀
- 백트래킹
- 9020
- 개발환경
- 티스토리챌린지
- 1101
- 신경망 학습
- 오블완
- video retireval
- 밑바닥부터 시작하는 딥러닝
- 파이썬
- 그리디 알고리즘
- 가상환경
- BOJ
- REST API
- streamlit
- pyenv
- 파이싼
- 백준
- 15649
- n과 m
- 1002
Archives
- Today
- Total
파이톨치
[백준] 1021 본문
728x90
# 1 2 3 4 5 6 7 8 9 10 # 0번
# 2 3 4 5 6 7 8 9 10 1 # 1번
# 9 10 1 3 4 5 6 7 8 # 3번
# 5 6 7 8 9 10 1 3 4 # 4번
from collections import deque
n, m = map(int, input().split())
queue = deque([i for i in range(1, n+1)])
# print(queue)
answer = list(map(int, input().split()))
cnt = 0
for i in range(m):
if queue.index(answer[i]) >= len(queue)/2:
while queue[0] != answer[i]:
queue.rotate(1)
cnt += 1
queue.popleft()
else:
while queue[0] != answer[i]:
queue.rotate(-1)
cnt += 1
queue.popleft()
print(cnt)
728x90