21.05.14 기록
-
백준 알고리즘 1546 풀이 완료
- 내가 푼 1546 풀이 (메모리 14.7MB, 시간 136ms로 통과)
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B1546 { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { int N = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int M = -1; int[] score = new int[N]; for(int i = 0; i < N; i++) { score[i] = Integer.parseInt(st.nextToken()); if(score[i] > M) M = score[i]; } double sum = 0; for(int i : score) { sum += i /(double) M * 100; } System.out.println(sum / N); } catch (IOException e) { e.printStackTrace(); } } }- 나의 풀이와 찾아본 풀이가 크게 차이가 없어서 내 풀이만 남긴다.
- 같은 로직으로 배열을 제외하고도 풀 수 있다.