-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNo_2839.java
More file actions
32 lines (27 loc) · 786 Bytes
/
No_2839.java
File metadata and controls
32 lines (27 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Problem_2839_설탕 배달
https://www.acmicpc.net/problem/2839
*/
import java.io.*;
import java.util.Arrays;
public class No_2839 {
final static int THREE = 3;
final static int FIVE = 5;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(br.readLine());
int[] dic = new int[num + 3];
Arrays.fill(dic, 9999);
dic[3] = 1; dic[5] = 1;
for(int i = 6; i <= num; i++) {
dic[i] = (Math.min(dic[i-3], dic[i-5]) + 1);
}
if(dic[num] >= 9999) {
System.out.println(-1);
}
else {
System.out.println(dic[num]);
}
br.close();
}
}