시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 9 8 7 100.000%

문제

알렉스는 이삿짐센터를 운영하고 있다. 오늘 이사해야 하는 집에는 무게가 1kg인 물건이 A개, 2kg인 물건이 B개, 3kg인 물건이 C개, 4kg인 물건이 D개, 5kg인 물건이 E개 있다.

물건을 운반하려면 바구니에 물건을 담아야 하는데, 바구니에는 최대 5kg까지 물건을 담을 수 있다. 알렉스는 모든 물건을 담는데 필요한 바구니 개수를 최소로 하려고 한다.

가방 하나에 담은 물건 무게의 합은 5kg을 넘을 수 없다.

물건의 무게가 주어졌을 때, 모든 물건을 담는데 필요한 바구니 개수의 최솟값을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 A, B, C, D, E가 주어진다. (0 ≤ A, B, C, D, E ≤ 1,000)

출력

첫째 줄에 모든 물건을 담는데 필요한 바구니 개수의 최솟값을 출력한다.

예제 입력 1

5 0 0 0 0

예제 출력 1

1

예제 입력 2

0 0 0 0 5

예제 출력 2

5

예제 입력 3

1 1 1 1 1

예제 출력 3

3

예제 입력 4

10 8 2 7 3

예제 출력 4

15

예제 입력 5

8 2 7 3 0

예제 출력 5

10
W3sicHJvYmxlbV9pZCI6IjE2MjM3IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVjNzc0XHVjMGJmXHVjOWQwXHVjMTNjXHVkMTMwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWM1NGNcdWI4MDlcdWMyYTRcdWIyOTQgXHVjNzc0XHVjMGJmXHVjOWQwXHVjMTNjXHVkMTMwXHViOTdjIFx1YzZiNFx1YzYwMVx1ZDU1OFx1YWNlMCBcdWM3ODhcdWIyZTQuIFx1YzYyNFx1YjI5OCBcdWM3NzRcdWMwYWNcdWQ1NzRcdWM1N2MgXHVkNTU4XHViMjk0IFx1YzlkMVx1YzVkMFx1YjI5NCBcdWJiMzRcdWFjOGNcdWFjMDAgMWtnXHVjNzc4IFx1YmIzY1x1YWM3NFx1Yzc3NC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