시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 1209 422 317 35.779%

문제

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

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

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

입력

첫째 줄에 N(1≤N≤500,000)이 주어진다. 다음 세 개의 줄에는 각 시험에서 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
W3sicHJvYmxlbV9pZCI6IjIzMzYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFkNDlcdWM3YTVcdWQ1NWMgXHVkNTU5XHVjMGRkIiwiZGVzY3JpcHRpb24iOiI8cD5OXHViYTg1XHVjNzU4IFx1ZDU1OVx1YzBkZFx1Yzc3NCBcdWNjMzhcdWM1ZWNcdWQ1NThcdWM1ZWMgXHVjMTM4IFx1YmM4OFx1Yzc1OCBcdWMyZGNcdWQ1ZDhcdWM3NDQgXHVjZTU4XHViODAwXHViMmU0LiBOXHViYTg1XHVjNzU4IFx1ZDU1OVx1YzBkZFx1YjRlNFx1Yzc0MCBcdWMxMzggXHViYzg4XHVjNzU4IFx1YzJkY1x1ZDVkOFx1YzVkMCBcdWJhYThcdWI0NTAgXHVjNzUxXHVjMmRjXHVkNTU4XHVjNjAwXHViMmU0LiBcdWM4NzBcdWFkNTBcdWIyOTQgXHVhYzAxXHVhYzAxXHVjNzU4IFx1YzJkY1x1ZD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NoIGZvciBnaXZlbiBOIGFuZCB0aGUgdGhyZWUgY29tcGV0aXRpb25zIHJlc3VsdHMsIGNvbXB1dGVzIHRoZSBudW1iZXIgb2YgZXhjZWxsZW50IGNvbnRlc3RhbnRzLjxcL3A+XHJcbiIsImlucHV0IjoiPHA+VGhlIGlucHV0IGRhdGEgYXJlIGdpdmVuIG9uIHRoZSBzdGFuZGFyZCBpbnB1dCBhcyBmb3VyIGxpbmVzLiBUaGUgZmlyc3QgbGluZSBjb250YWlucyB0aGUgbnVtYmVyIE4uIFRoZSBuZXh0IHRocmVlIGxpbmVzIHNob3cgdGhlIHJhbmtpbmdzIGZvciB0aGUgdGhyZWUgY29tcGV0aXRpb25zLiBFYWNoIG9mIHRoZXNlIGxpbmVzIGNvbnRhaW5zIHRoZSBpZGVudGlmaWNhdGlvbiBudW1iZXJzIG9mIHRoZSBjb250ZXN0YW50cywgc2VwYXJhdGVkIGJ5IHNpbmdsZSBzcGFjZXMsIGluIHRoZSBvcmRlciBvZiB0aGVpciByYW5raW5nIGZyb20gZmlyc3QgdG8gbGFzdCBwbGFjZS48XC9wPlxyXG5cclxuPHA+Jm5ic3A7PFwvcD5cclxuIiwib3V0cHV0IjoiPHA+VGhlIHN0YW5kYXJkIG91dHB1dCBzaG91bGQgY29udGFpbiBvbmUgbGluZSB3aXRoIGEgc2luZ2xlIG51bWJlciB3cml0dGVuIG9uIGl0OiB0aGUgbnVtYmVyIG9mIHRoZSBleGNlbGxlbnQuPFwvcD5cclxuXHJcbjxwPiZuYnNwOzxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

Olympiad > Balkan Olympiad in Informatics > BOI 2004 2번

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