Logo
(追記) (追記ここまで)

30314번 - Just a Joystick 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB36130227484.568%

문제

You just got the high score when playing Battlezone Asteroids Pac-Centipede on an arcade machine! On the "Game Over" screen, you can enter your initials, one letter at a time. This seems to be a very modern arcade machine: whereas the original arcade machines only allowed entering three initials, this machine allows many more. However, to select the letters, you have access to just a joystick. For every letter, you need to move the joystick up or down to cycle between the letters (wrapping around between 'Z' and 'A', in both directions) and move it to the right to move to the next letter.

It appears that the initials of the previous high-score winner are still filled in. Entering your own initials is going to take some time, and you want to know exactly how long. How many times do you need to you move the joystick up or down to enter your own initials, if you do so in the most efficient way?

입력

The input consists of:

  • One line with an integer $n$ (1ドル \leq n \leq 10^5$), the number of letters available to enter your initials.
  • One line with a string of length $n,ドル the initials of the previous high-score winner.
  • One line with a string of length $n,ドル the initials that you want to enter.

The strings only consist of English uppercase letters (A-Z).

출력

Output the minimum number of times you should move the joystick up or down to enter your own initials. This does not include the number of times that you need to move the joystick to the right.

제한

예제 입력 1

3
RGK
MPS

예제 출력 1

22

예제 입력 2

5
ABIYZ
YZIAB

예제 출력 2

8

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2023 Preliminaries J번

  • 문제를 만든 사람: Maarten Sijm
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /