시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 192 MB 1673 634 464 38.538%

문제

N명의 학생이 참여하여 세 번의 시험을 치렀다. N명의 학생들은 세 번의 시험에 모두 응시하였다. 조교는 각각의 시험에서 같은 등수의 학생이 한 명도 없도록 성적을 매겼다.

A라는 학생이 B라는 학생보다 세 번의 시험에서 모두 성적이 좋다면, A가 B보다 '대단하다'고 한다. 또, C라는 학생보다 '대단한' 학생이 한 명도 없으면, C를 '굉장하다'고 한다.

세 번의 시험에서 각 학생의 성적이 주어졌을 때, '굉장한' 학생의 수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 N(1 ≤ N ≤ 500,000)이 주어진다. 다음 세 개의 줄에는 각 시험에서 1등인 학생부터 N등인 학생이 순서대로 주어진다. 학생의 번호는 1부터 N까지 매겨져 있다.

출력

첫째 줄에 '굉장한' 학생의 수를 출력한다.

예제 입력 1

10
2 5 3 8 10 7 1 6 9 4
1 2 3 4 5 6 7 8 9 10
3 8 7 10 5 4 1 2 6 9

예제 출력 1

4
W3sicHJvYmxlbV9pZCI6IjIzMzYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFkNDlcdWM3YTVcdWQ1NWMgXHVkNTU5XHVjMGRkIiwiZGVzY3JpcHRpb24iOiI8cD5OXHViYTg1XHVjNzU4IFx1ZDU1OVx1YzBkZFx1Yzc3NCBcdWNjMzhcdWM1ZWNcdWQ1NThcdWM1ZWMgXHVjMTM4IFx1YmM4OFx1Yzc1OCBcdWMyZGNcdWQ1ZDhcdWM3NDQgXHVjZTU4XHViODAwXHViMmU0LiBOXHViYTg1XHVjNzU4IFx1ZDU1OVx1YzBkZFx1YjRlNFx1Yzc0MCBcdWMxMzggXHViYzg4XHVjNzU4IFx1YzJkY1x1ZDVkOFx1YzVkMCBcdWJhYThcdWI0NTAgXHVjNzUxXHVjMmRjXHVkNTU4XHVjNjAwXHViMmU0LiBcdWM4NzBcdWFkNTBcdWIyOTQgXHVhYzAx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nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

Olympiad > Balkan Olympiad in Informatics > BOI 2004 2번

  • 잘못된 데이터를 찾은 사람: tncks0121