-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_1546.java
More file actions
68 lines (54 loc) ยท 1.31 KB
/
_1546.java
File metadata and controls
68 lines (54 loc) ยท 1.31 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
package backjoon;
// https://www.acmicpc.net/problem/1546
// ํ๊ท
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class _1546 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cntSubject = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int max = 0;
// sol1. ๋ฐฐ์ด์ฌ์ฉ
// memory 11912 runtime 88
/*
double[] arr = new double[cntSubject];
double newSum = 0;
// ์ต๋๊ฐ ๊ตฌํ๊ธฐ
for(int i=0; i<cntSubject; i++){
arr[i] = Integer.parseInt(st.nextToken());
max = (int) Math.max(arr[i], max);
}
// ํ๊ท ๊ตฌํ๊ธฐ
for(double score : arr){
newSum += score/max*100;
}
System.out.println(newSum/cntSubject);
*/
// sol2 ๋ฐฐ์ด์ฌ์ฉํ์ง์๊ณ ํ๊ธฐ
// memory 11780 runtime 84
double newSum = 0.0;
for (int i = 0; i < cntSubject; i++) {
int value = Integer.parseInt(st.nextToken());
if(value > max) {
max = value;
}
newSum += value;
}
System.out.println( ((newSum/max)*100.0)/cntSubject );
}
}
/*
input
3
40 80 60
output
75.0
input
5
1 2 4 8 16
output
38.75
*/