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

13148번 - Correcting Cheeseburgers 다국어

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

문제

Cheeseburgers are serious business. They are the most delicious food on earth, but there is a lot of room for error when making a cheeseburger. Even otherwise capable cooks often mess up the order of the assembled ingredients.

The only correct order of ingredients between the buns is, of course, as following from top to bottom:

  1. Ketchup & Mustard
  2. Beef Tomato
  3. Pickles
  4. Red Onions
  5. Cheddar Cheese
  6. Garlic
  7. Salt & Pepper
  8. Beef Patty, medium grilled
  9. Corn Salad
  10. Mayonnaise

Any deviation from this order is completely unacceptable. Therefore it is sometimes necessary to reassemble a cheeseburger.

Space on an average plate and social norms are rather restrictive when it comes to operating on a cheeseburger. The only feasible operation is the bit-shuffle (burger-ineptly-transformed). The bit-shuffle separates the entire burger into four parts of contiguous ingredients a, b, c and d and arranges them in the new order c a d b. The size of each of the four parts is selectable and may be zero.

Since the burger cools rapidly we are interested in the minimum required bit-shuffles to arrive at an acceptable burger.

Each given cheeseburger consists of n unique ingredients labeled from 1 to n. The correct order is always the natural order 1 2 . . . n.

Figure B.1: Illustration of the first sample input.

Figure B.2: Illustration of the second sample input.

입력

The input consists of:

  • one line with an integer n (1 ≤ n ≤ 10), where n is the number of ingredients used;
  • one line with n integers describing the order of the ingredients of the given cheeseburger. The ingredients are numbered from 1 to n.

출력

Output the minimum number of bit-shuffles to correct the given cheeseburger.

제한

예제 입력 1

9
3 4 7 8 9 1 2 5 6

예제 출력 1

1

예제 입력 2

3
1 3 2

예제 출력 2

1

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2016 B번

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

출처

대학교 대회

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

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