728x90
반응형
# 18238
tmp = input()
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

cnt = 0 
now = alpha.index('A')

for i in tmp:
  start = alpha.index(i)
  if abs(start-now) > 12 :
    cnt = cnt+ 26 - abs(start-now)
  else:
    cnt = cnt + abs ( start-now )
  now = start

print (cnt) 
728x90
반응형

'백준 > 그리디' 카테고리의 다른 글

# 10162 전자레인지  (0) 2020.09.02
# 5585 거스름돈  (0) 2020.09.02
# 11399 ATM  (0) 2020.09.02
# 14241 슬라임 합치기  (0) 2020.09.02
# 16208 귀찮음  (0) 2020.09.01

+ Recent posts