-
[Softeer] 성적 평균 (lv.3)ALGORITHM/SWEXPERT|SOFTEER 2021. 11. 2. 22:42
https://softeer.ai/practice/info.do?eventIdx=1&psProblemId=389
2021
1234567891011121314151617181920212223242526272829import java.util.*;import java.io.*;public class Main{public static int N, K;public static void main(String[] args) throws IOException {BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));StringTokenizer st = new StringTokenizer(bf.readLine());N = Integer.parseInt(st.nextToken());K = Integer.parseInt(st.nextToken());st = new StringTokenizer(bf.readLine());int[] arr = new int[N+1];for(int i = 1; i <= N; i++) {int value = Integer.parseInt(st.nextToken());arr[i] = arr[i-1] + value;}for(int i = 0; i < K; i++) {st = new StringTokenizer(bf.readLine());int a = Integer.parseInt(st.nextToken());int b = Integer.parseInt(st.nextToken());double value = (arr[b] - arr[a-1])/(double)(b-a+1);System.out.println(String.format("%.2f", value));}}}cs 'ALGORITHM > SWEXPERT|SOFTEER' 카테고리의 다른 글
[Softeer] 장애물 인식 프로그램 (lv.2) (0) 2021.11.02 [Softeer] 8단 변속기 (lv.2) (0) 2021.11.02 [Softeer] 바이러스 (lv.2) (0) 2021.11.02 [시뮬레이션] 5658 :: 보물상자 비밀번호 (0) 2018.10.03 [BFS] 1953::탈주범 검거 (0) 2018.10.02