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

17803번 - Jammed Gym 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB57323167.391%

문제

You are at the fitness centre to run through your exercise programme. You must use the kinds of exercise machine in an order precisely dictated by the programme, although there may be more than one instance of a machine.

You start at the centre of a unit circle around which the exercise stations are arranged. You can walk directly between any two points in the circle, and you may also visit the same point multiple times. See Figure J.1 below for an example.

Figure J.1: Illustration of Sample Input 1. Types of machine: [1, 2, 4, 1, 3, 2]

Exercise is an important and noble endeavour, but in today’s busy world we must strive for efficiency in everything we do. Find the most efficient way of visiting exercise stations that matches the order given.

입력

  • The first line of input contains the number of exercises in the programme, n (1 ≤ n ≤ 100).
  • The second line of input contains n space-separated integers each denoting the type of an item on the programme t (1 ≤ ti ≤ 100). There will always be at least one station for each programme in this list.
  • The third line of input contains the number of stations, m (1 ≤ m ≤ 100).
  • The fourth line of input contains m space-separated integers each denoting the type of a station q (1 ≤ qi ≤ 100).

출력

Output the minimum distance you will need to walk. Your answer must be accurate to an absolute or relative error of 10−6.

제한

예제 입력 1

6
1 2 4 1 3 2
5
1 4 2 2 3

예제 출력 1

7.604395

예제 입력 2

5
4 2 1 3 1
6
1 2 1 3 1 4

예제 출력 2

5.732051

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2019 J번

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

출처

대학교 대회

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

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