forked from sowon-dev/AlgorithmStudy_Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_2562.java
More file actions
63 lines (54 loc) ยท 1.24 KB
/
_2562.java
File metadata and controls
63 lines (54 loc) ยท 1.24 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
package backjoon;
// https://www.acmicpc.net/problem/2562
// ์ต๋๊ฐ
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class _2562 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int max = 0; //์์ฐ์๊ฐ ์ฃผ์ด์ง๋ฏ๋ก ์ ์ธ์ Integer.MIN_VALUE์ด ์๋ 0์ผ๋ก ํจ
int i = 0; //์ธ๋ฑ์ค๊ฐ
int[] arr = new int[9]; //์๋ก ๋ค๋ฅธ 9๊ฐ์ ์์ฐ์๋ฅผ ๋ฃ์ ๋ฐฐ์ด
// sol1 memory 11476 runtime 76
/*
//๋ฐฐ์ด์ ์ซ์๋ฃ๊ธฐ -> ๋ฐฐ์ด์ด ์์ด์ผ์ง index๊ฐ์ ๊ตฌํ ์ ์์
for(i=0; i<arr.length; i++){
arr[i] = Integer.parseInt(br.readLine());
max = Math.max(arr[i], max);
}
//๋ฐฐ์ด ์ธ๋ฑ์ค ๊ตฌํ๊ธฐ
for(int j =0; j<arr.length; j++){
if(arr[j] == max){
i = j+1;
}
}
*/
// sol2 for๋ฌธ ํ๋ฒ๋ง ์ฌ์ฉํ๊ธฐ
// memory 11444 runtime 76
for(int j=0; j<arr.length;j++) {
arr[j] = Integer.parseInt(br.readLine());
if(max < arr[j]) {
max = arr[j];
i = j+1;
}
}
System.out.println(max);
System.out.println(i);
}
}
/*
input
3
29
38
12
57
74
40
85
61
output
85
8
*/