-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp1.java
More file actions
94 lines (86 loc) · 1.9 KB
/
p1.java
File metadata and controls
94 lines (86 loc) · 1.9 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
ID: grifync1
LANG: JAVA
PROG: whatbase
*/
//lil lil peezy
import java.util.*;
import java.io.*;
public class p1 {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
//StringTokenizer st = new StringTokenizer(in.readLine());
StringTokenizer st = new StringTokenizer(in.readLine());
int n = Integer.parseInt(st.nextToken());
int k = Integer.parseInt(st.nextToken());
int[] an = new int[n];
for(int i=0; i<n; i++) {
an[i]=Integer.parseInt(in.readLine());
}
Arrays.sort(an);
Map<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>();
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
if(j==i)
continue;
else {
if(an[i]-an[j]<12 && an[i]-an[j]>0) {
if(map.containsKey(an[i])) {
List<Integer> l = map.get(an[i]);
l.add(an[j]);
map.put(an[i], l);
}
else {
List<Integer> l = new ArrayList<Integer>();
l.add(an[j]);
map.put(an[i], l);
}
}
}
}
}
int ans = 0;
for(int i: an) {
if(!map.containsKey(i)) {
ans+=12;
}
}
Map<Integer, Integer> sco = new HashMap<Integer, Integer>();
for(Integer key: map.keySet()) {
List<Integer> l = map.get(key);
Collections.sort(l);
if(!sco.containsKey(l.get(0))) {
int c = (int) ((key)-(Math.floor(l.get(0)/12)*12));
if(c<12) {
c=12;
}
else {
c=(int) (12*(Math.ceil(c/12)));
}
ans+=c;
sco.put(l.get(0), c);
}
else {
int c = (int) ((key)-(Math.floor(l.get(0)/12)*12));
if(c<12) {
c=12;
}
else {
c=(int) (12*(Math.ceil(c/12)));
}
if(sco.get(l.get(0))>c) {
sco.put(l.get(0), c);
ans-=sco.get(l.get(0));
ans+=c;
}
else {
continue;
}
}
}
out.println(ans);
in.close();
out.close();
}
}