Skip to content

Commit 09842dd

Browse files
committed
1015
1 parent 6171389 commit 09842dd

File tree

5 files changed

+110
-0
lines changed

5 files changed

+110
-0
lines changed

.idea/modules.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BOJ/gold/BOJ1339/BOJ1339.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

BOJ/gold/BOJ1339/src/Main.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
import java.util.*;
5+
6+
public class Main {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
int N = Integer.parseInt(br.readLine());
10+
11+
String[] words = new String[N];
12+
for (int i = 0; i < N; i++) {
13+
String s = br.readLine();
14+
words[i] = s;
15+
}
16+
int[] alpa = new int[26];
17+
for (int i = 0; i < words.length; i++) {
18+
for (int j = 0; j < words[i].length(); j++) {
19+
char tmp = words[i].charAt(j);
20+
int placeCount = (int) Math.pow(10, words[i].length() - j - 1);
21+
alpa[tmp - 'A'] +=placeCount;
22+
}
23+
}
24+
List<wordList> wl = new LinkedList<>();
25+
for (int i = 0; i < alpa.length ; i++) {
26+
wl.add(new wordList(alpa[i],(char)('A'+i)));
27+
}
28+
wl.sort(wordList::compareTo);
29+
30+
int num=9;
31+
for (int i = wl.size()-1; i >=0 ; i--) {
32+
if(num<0){
33+
break;
34+
}
35+
alpa[(int)wl.get(i).c-'A']= wl.get(i).cost*num;
36+
num--;
37+
}
38+
int total=0;
39+
for (int i = 0; i < alpa.length; i++) {
40+
total+=alpa[i];
41+
}
42+
System.out.println(total);
43+
44+
45+
}
46+
}
47+
48+
class wordList implements Comparable<wordList>{
49+
int cost;
50+
char c;
51+
52+
public wordList(int cost, char c) {
53+
this.cost = cost;
54+
this.c = c;
55+
}
56+
57+
@Override
58+
public int compareTo(wordList o) {
59+
return cost-o.cost;
60+
}
61+
}

BOJ/gold/BOJ1715/BOJ1715.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

BOJ/gold/BOJ1715/src/Main.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.*;
2+
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
int N = sc.nextInt();
8+
int[] cards = new int[N];
9+
PriorityQueue<Long> dq = new PriorityQueue<>();
10+
for (int i = 0; i < N; i++) {
11+
dq.offer(sc.nextLong());
12+
}
13+
14+
long num = 0;
15+
while (dq.size() > 1) {
16+
long tmp1 = dq.poll();
17+
long tmp2 = dq.poll();
18+
num += tmp1 + tmp2;
19+
dq.offer(tmp1 + tmp2);
20+
}
21+
System.out.println(num);
22+
23+
}
24+
25+
}

0 commit comments

Comments
 (0)