This problem is in Contest(s) below:
Contest 1035:컴퓨터알고리즘 중간 과제용 콘테스트
Contest 1043:데이터구조 첫번째 과제용 콘테스트