시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB172645938730.521%

문제

2890번을 보면 알겠지만, 상근이는 카약 대회를 개최했다. 그런데, 갑자기 엄청난 강풍이 경기장에 불었고, 일부 카약이 부서졌다. 경기는 5분 안에 시작해야 하는 상황이다.

다행히 일부 팀은 혹시 모를 사태에 대비해서 카약을 하나 더 경기장에 들고 왔다. 카약은 매우 무겁고 운반하기 어렵다. 따라서, 자신의 바로 다음이나 전에 경기하는 팀에게만 카약을 빌려주려고 한다. 즉, 팀 4는 여분의 카약을 3이나 5에게만 빌려줄 수 있다. 다른 팀에게서 받은 카약은 또 다른 팀에게 빌려줄 수 없다. 또, 카약을 하나 더 가져온 팀의 카약이 손상되었다면, 여분의 카약으로 경기에 출전하게되고, 이 카약은 다른 팀에게 빌려줄 수 없다.

카약이 부서진 팀과 하나 더 가져온 팀이 주어진다. 카약을 적절히 빌렸을 때 출발하지 못하는 팀의 최솟값은 몇 팀인지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 팀의 수 N, 카약이 손상된 팀의 수 S, 카약을 하나 더 가져온 팀의 수 R이 주어진다. (2 ≤ N ≤ 10, 1 ≤ S, R ≤ N)

둘째 줄에는 카약이 손상된 팀의 번호가 주어진다. 팀 번호는 중복되지 않는다.

셋째 줄에는 카약을 하나 더 가져온 팀의 번호가 주어진다. 팀 번호는 중복되지 않는다.

출력

첫째 줄에 출발을 할 수 없는 팀의 최솟값을 출력한다.

예제 입력 1

5 2 1
2 4
3

예제 출력 1

1

예제 입력 2

5 2 3
2 4
1 3 5

예제 출력 2

0
W3sicHJvYmxlbV9pZCI6IjI4OTEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWNlNzRcdWM1N2RcdWFjZmMgXHVhYzE1XHVkNDhkIiwiZGVzY3JpcHRpb24iOiI8cD48YSBocmVmPVwiXC9wcm9ibGVtXC8yODkwXCI+Mjg5MFx1YmM4ODxcL2E+XHVjNzQ0IFx1YmNmNFx1YmE3N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ciBvZiB0ZWFtcyB3aXRoIGRhbWFnZWQga2F5YWtzIGFuZCBSLCAoMSZuYnNwOyZsZTsgUiAmbGU7IE4pLCBudW1iZXIgZm8gdGVhbXMgd2l0aCByZXNlcnZlIGtheWFrcy48XC9wPlxyXG5cclxuPHA+VGhlIHNlY29uZCBsaW5lIGNvbnRhaW5zIGV4YWN0bHkgUyBudW1iZXJzLCB0aGUgc3RhcnRpbmcgbnVtYmVycyBvZiB0ZWFtcyB3aXRoIGRhbWFnZWQga2F5YWtzLiBUaGUgc2Vjb25kIGxpbmUgd2lsbCBub3QgY29udGFpbiBkdXBsaWNhdGVzLjxcL3A+XHJcblxyXG48cD5UaGUgdGhpcmQgbGluZSBjb250YWlucyBleGFjdGx5IFIgbnVtYmVycywgdGhlIHN0YXJ0aW5nIG51bWJlcnMgb2YgdGVhbXMgd2l0aCByZXNlcnZlIGtheWFrcy4gVGhlIHRoaXJkIGxpbmUgd2lsbCBub3QgY29udGFpbiBkdXBsaWNhdGVzLjxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPlRoZSBmaXJzdCBhbmQgb25seSBsaW5lIG9mIG91dHB1dCBzaG91bGQgY29udGFpbiB0aGUgc21hbGxlc3QgbnVtYmVyIG9mIHRlYW1zIHRoYXQgY2Fubm90IHN0YXJ0IHRoZSBjb21wZXRpdGlvbi48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwiaHRtbF90aXRsZSI6IjAiLCJwcm9ibGVtX2xhbmdfdGNvZGUiOiJFbmdsaXNoIn1d

출처

Contest > Croatian Open Competition in Informatics > COCI 2009/2010 > Contest #6 2번