Skip to content

Commit a82c249

Browse files
feat: 백준 문제 풀이 추가
1 parent 709e05b commit a82c249

File tree

7 files changed

+214
-0
lines changed

7 files changed

+214
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package sgyj.backjun.seunggu;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.util.Arrays;
7+
public class Main10807 {
8+
public static void main (String[] args) {
9+
try ( BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
10+
int number = Integer.parseInt(reader.readLine());
11+
int[] array = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
12+
int compareNumber = Integer.parseInt(reader.readLine());
13+
long count = Arrays.stream(array).filter(s -> s == compareNumber).count();
14+
System.out.println(count);
15+
}catch ( IOException e) {
16+
e.printStackTrace();
17+
}
18+
}
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package sgyj.backjun.seunggu;
2+
3+
import java.io.*;
4+
5+
public class Main25304 {
6+
7+
public static void main(String[] args) {
8+
try ( BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
9+
int totalCost = Integer.parseInt(reader.readLine());
10+
int totalAmount = Integer.parseInt(reader.readLine());
11+
int sumCost = 0;
12+
for(int i=0; i<totalAmount; i++) {
13+
String[] items = reader.readLine().split(" ");
14+
int cost = Integer.parseInt(items[0]);
15+
int amount = Integer.parseInt(items[1]);
16+
sumCost += (cost * amount);
17+
}
18+
if(totalCost == sumCost) {
19+
System.out.println("Yes");
20+
} else {
21+
System.out.println("No");
22+
}
23+
} catch (Exception e) {
24+
e.printStackTrace();
25+
}
26+
}
27+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package sgyj.backjun.seunggu;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.util.Arrays;
7+
import java.util.Comparator;
8+
import java.util.List;
9+
import java.util.stream.Collectors;
10+
11+
public class Main25305 {
12+
13+
public static void main( String[] args ) {
14+
try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
15+
String[] scores = reader.readLine().split(" ");
16+
int number = Integer.parseInt(scores[0]);
17+
int cutLine = Integer.parseInt(scores[1]);
18+
List<Integer> array = Arrays.stream( reader.readLine().split( " ")).mapToInt( Integer::parseInt).boxed().sorted( Comparator.reverseOrder() ).collect( Collectors.toList());
19+
20+
System.out.println(array.get( cutLine-1 )) ;
21+
} catch ( IOException e ) {
22+
e.printStackTrace();
23+
}
24+
}
25+
26+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package sgyj.backjun.seunggu;
2+
3+
import java.io.BufferedReader;
4+
import java.io.InputStreamReader;
5+
6+
public class Main2563 {
7+
8+
private static final int[][] array = new int[100][100];
9+
10+
public static void main (String[] args) {
11+
try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
12+
int count = Integer.parseInt(reader.readLine());
13+
for(int i=0; i<count; i++) {
14+
String[] numbers = reader.readLine().split(" ");
15+
fillArray(Integer.parseInt(numbers[0]), Integer.parseInt(numbers[1]));
16+
}
17+
int fillArea = 0;
18+
for(int i=0; i<100; i++) {
19+
for(int j=0; j <100; j++) {
20+
if(array[i][j] == 1) {
21+
fillArea++;
22+
}
23+
}
24+
}
25+
System.out.println(fillArea);
26+
27+
}catch (Exception e) {
28+
e.printStackTrace();
29+
}
30+
}
31+
32+
static void fillArray(int x, int y) {
33+
for(int i=0; i<10; i++) {
34+
for(int j=0; j<10; j++) {
35+
array[x+i][y+j] = 1;
36+
}
37+
}
38+
}
39+
40+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package sgyj.backjun.seunggu;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
6+
public class Main2566 {
7+
8+
public static void main( String[] args ) {
9+
try ( BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
10+
int[][] array = new int[9][9];
11+
for(int i=0; i<9; i++) {
12+
array[i] = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
13+
}
14+
int max = Integer.MIN_VALUE;
15+
String location = "";
16+
for(int i=0; i<array.length; i++) {
17+
int[] arr = array[i];
18+
for(int j=0; j<arr.length; j++) {
19+
int number = arr[j];
20+
if(number > max) {
21+
max = number;
22+
location = (i+1) + " " + (j+1);
23+
}
24+
}
25+
}
26+
System.out.println(max);
27+
System.out.println(location);
28+
}catch(Exception e ) {
29+
e.printStackTrace();
30+
}
31+
}
32+
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package sgyj.backjun.seunggu;
2+
3+
import java.io.BufferedReader;
4+
import java.io.InputStreamReader;
5+
import java.io.IOException;
6+
import java.util.Arrays;
7+
8+
public class Main2587 {
9+
10+
public static void main (String[] args) {
11+
try ( BufferedReader reader = new BufferedReader( new InputStreamReader(System.in))) {
12+
int[] array = new int[5];
13+
int sum = 0;
14+
for(int i=0; i<5; i++) {
15+
array[i] = Integer.parseInt(reader.readLine());
16+
sum += array[i];
17+
}
18+
Arrays.sort(array);
19+
System.out.println(sum/5);
20+
System.out.println(array[2]);
21+
22+
} catch (IOException e ) {
23+
e.printStackTrace();
24+
}
25+
}
26+
27+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package sgyj.backjun.seunggu;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
public class Main2738 {
6+
7+
public static void main( String[] args ) {
8+
try ( BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
9+
String[] line = reader.readLine().split(" ");
10+
int firstCount = Integer.parseInt(line[0]);
11+
int secondCount = Integer.parseInt(line[1]);
12+
int[][] firstArray = new int[firstCount][secondCount];
13+
int[][] secondArray = new int[firstCount][secondCount];
14+
makeArray(firstArray, reader, firstCount);
15+
makeArray(secondArray, reader, firstCount);
16+
int[][] resultArray = new int[firstCount][secondCount];
17+
for(int i=0; i< firstCount; i++) {
18+
for(int j=0; j<secondCount; j++) {
19+
resultArray[i][j] = firstArray[i][j] + secondArray[i][j];
20+
}
21+
}
22+
StringBuilder stringBuilder = new StringBuilder();
23+
for(int i=0; i< firstCount; i++) {
24+
for(int j=0; j<secondCount; j++) {
25+
stringBuilder.append(resultArray[i][j]).append(" ");
26+
}
27+
stringBuilder.append("\n");
28+
}
29+
System.out.println(stringBuilder);
30+
31+
}catch(Exception e ) {
32+
e.printStackTrace();
33+
}
34+
}
35+
36+
private static void makeArray(int[][] array, BufferedReader reader, int count) throws IOException {
37+
for(int i=0; i< count; i++) {
38+
array[i] = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
39+
}
40+
}
41+
42+
}

0 commit comments

Comments
 (0)