시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 58998 14979 12192 27.688%

문제

상근이는 요즘 설탕공장에서 설탕을 배달하고 있다. 상근이는 지금 사탕가게에 설탕을 정확하게 N킬로그램을 배달해야 한다. 설탕공장에서 만드는 설탕은 봉지에 담겨져 있다. 봉지는 3킬로그램 봉지와 5킬로그램 봉지가 있다.

상근이는 귀찮기 때문에, 최대한 적은 봉지를 들고 가려고 한다. 예를 들어, 18킬로그램 설탕을 배달해야 할 때, 3킬로그램 봉지 6개를 가져가도 되지만, 5킬로그램 3개와 3킬로그램 1개를 배달하면, 더 적은 개수의 봉지를 배달할 수 있다.

상근이가 설탕을 정확하게 N킬로그램 배달해야 할 때, 봉지 몇 개를 가져가면 되는지 그 수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 N이 주어진다. (3 ≤ N ≤ 5000)

출력

상근이가 배달하는 봉지의 최소 개수를 출력한다. 만약, 정확하게 N킬로그램을 만들 수 없다면 -1을 출력한다.

예제 입력 1

18

예제 출력 1

4

예제 입력 2

4

예제 출력 2

-1

예제 입력 3

6

예제 출력 3

2

예제 입력 4

9

예제 출력 4

3

예제 입력 5

11

예제 출력 5

3
W3sicHJvYmxlbV9pZCI6IjI4MzkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMxMjRcdWQwZDUgXHViYzMwXHViMmVjIiwiZGVzY3JpcHRpb24iOiI8cD5cdWMwYzFcdWFkZmNcdWM3NzRcdWIyOTQgXHVjNjk0XHVjOTk4IFx1YzEyNFx1ZDBkNVx1YWNmNVx1YzdhNVx1YzVkMFx1YzExYyBcdWMxMjRcdWQwZDVcdWM3NDQgXHViYzMwXHViMmVjXHVkNTU4XHVhY2UwIFx1Yzc4OFx1YjJlNC4gXHVjMGMxXHVhZGZjXHVjNzc0XHViMjk0IFx1YzljMFx1YWUwOCBcdWMwYWNcdWQwZDVcdWFjMDBcdWFjOGNcdWM1ZDAgXHVjMTI0XHVkMGQ1XH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cywgYW5kIG9uZSAzLWtpbG9ncmFtIHBhY2thZ2UsIHJlc3VsdGluZyBpbiB0aGUgdG90YWwgb2YgZm91ciBwYWNrYWdlcy48XC9wPlxyXG5cclxuPHA+SGVscCBNaXJrbyBieSBmaW5kaW5nIHRoZSBtaW5pbXVtIG51bWJlciBvZiBwYWNrYWdlcyByZXF1aXJlZCB0byB0cmFuc3BvcnQgZXhhY3RseSBOIGtpbG9ncmFtcyBvZiBzdWdhci48XC9wPlxyXG4iLCJpbnB1dCI6IjxwPlRoZSBmaXJzdCBhbmQgb25seSBsaW5lIG9mIGlucHV0IGNvbnRhaW5zIG9uZSBpbnRlZ2VyIE4gKDMgJmxlOyBOICZsZTsgNTAwMCkuPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+VGhlIGZpcnN0IGFuZCBvbmx5IGxpbmUgb2Ygb3V0cHV0IHNob3VsZCBjb250YWluIHRoZSBtaW5pbXVtIG51bWJlciBvZiBwYWNrYWdlcyBNaXJrbyBoYXMgdG8gdXNlLiBJZiBpdCBpcyBpbXBvc3NpYmxlIHRvIGRlbGl2ZXIgZXhhY3RseSBOIGtpbG9ncmFtcywgb3V0cHV0IC0xLjxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

Contest > Croatian Open Competition in Informatics > COCI 2010/2011 > Contest #7 1번

  • 문제를 번역한 사람: baekjoon
  • 데이터를 추가한 사람: jh05013