結果

問題 No.1134 Deviation Score Ⅱ
ユーザー RISE70226821
提出日時 2020-08-03 16:59:14
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 1,272 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,780 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 53,748 KB
最終ジャッジ日時 2026-03-20 12:51:18
合計ジャッジ時間 10,295 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		int totalX = 0;
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			totalX += X[i];
		}
		int M = sc.nextInt();
		
		// 途中計算
		double ave = (double)totalX / N;

		//System.out.print("ave = ");
		//System.out.println(ave);

		double[] dif = new double[N];
		double totalDif = 0;
		for(int i = 0; i < N; i++){
			dif[i] = (X[i] - ave) * (X[i] - ave);
			totalDif += dif[i];
		}
		double difAve = Math.sqrt(totalDif / N);

		//System.out.print("totalDif = ");
		//System.out.println(totalDif);
		//System.out.print("difAve = ");
		//System.out.println(difAve);
		
		// 偏差値算出
		int result = 0;
		if(difAve == 0){
			result = 50;
		}else{
			int score = X[M-1];
			double tmp = (score - ave) * 10 / difAve;
			result = (int)(50 + tmp);
			//System.out.print("score = ");
			//System.out.println(score);
			//System.out.print("tmp = ");
			//System.out.println(tmp);
		}
		
		// 出力
		System.out.println(result);
	}

}
0