시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB60021114538.058%

문제

N명의 사람이 원판 테이블에 앉아서 콜라를 마시고 있다. 그 상황에서 두 사람이 짝을 지어서 건배를 하려 한다. 그런데 이들은 건배를 할 때, 보기 좋게 하기 위하여 마시고 있는 콜라의 브랜드가 같은 경우에만 건배를 할 수 있다고 한다. 그리고 사람들이 동시에 건배를 할 때, 사람들의 팔이 서로 엇갈리는 경우에는 건배를 할 수 없다고 한다.

예를 들어 왼쪽 그림과 같은 경우는 겹치는 경우가 없어 건배를 할 수 있으나 오른쪽과 같은 경우에는 건배를 할 수 없다. 사람의 수 N과 각각의 사람이 마시는 콜라의 브랜드가 주어져 있을 때, 동시에 건배를 할 수 있는 가장 많은 쌍의 개수를 출력하시오.

입력

첫 줄에 사람의 수 (1 ≤ N ≤ 1000) 이 주어진다. 그리고 둘째 줄에 N개의 정수(1 이상 100 이하)가 공백을 사이에 두고 주어지는데 이는 각각의 사람이 마시는 콜라의 브랜드이다. (시계방향순서대로 주어진다)

출력

동시에 건배를 할 수 있는 가장 많은 쌍의 개수를 출력한다.

예제 입력 1

22
1 7 1 2 4 2 4 9 1 1 9 4 5 9 4 5 6 9 2 1 2 9

예제 출력 1

8

예제 입력 2

6
1 2 2 1 3 3

예제 출력 2

3
W3sicHJvYmxlbV9pZCI6IjE5NzAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFjNzRcdWJjMzAiLCJkZXNjcmlwdGlvbiI6IjxwPk5cdWJhODVcdWM3NTggXHVjMGFjXHViNzhjXHVjNzc0IFx1YzZkMFx1ZDMxMCBcdWQxNGNcdWM3NzRcdWJlMTRcdWM1ZDAgXHVjNTQ5XHVjNTQ0XHVjMTFjIFx1Y2Y1Y1x1Yjc3Y1x1Yjk3YyBcdWI5YzhcdWMyZGNcdWFjZTAgXHVjNzg4XHViMmU0LiBcdWFkZjggXHVjMGMxXHVkNjY5XHVjNWQwXHVjMTFjIFx1YjQ1MCBcd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zaG91bGQgY29udGFpbiBhIHNpbmdsZSBudW1iZXIgb24gYSBzaW5nbGUgbGluZTogdGhlIG1heGltdW0gbnVtYmVyIG9mIG5vbi1pbnRlcnNlY3RpbmcgdG9hc3RzIG9mIHRoZSBzYW1lIGJlZXIgYnJhbmQgZm9yIHRoaXMgdGVzdCBjYXNlLjxcL3A+XHJcblxyXG48cD4mbmJzcDs8XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwiaHRtbF90aXRsZSI6IjAiLCJwcm9ibGVtX2xhbmdfdGNvZGUiOiJFbmdsaXNoIn1d

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2006 E번

  • 잘못된 조건을 찾은 사람: Apple_Cplus
  • 데이터를 추가한 사람: cgiosy