結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2016-01-19 17:37:46 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 61 ms / 1,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 2,142 ms |
コンパイル使用メモリ | 75,704 KB |
実行使用メモリ | 50,604 KB |
最終ジャッジ日時 | 2024-06-24 23:40:03 |
合計ジャッジ時間 | 5,660 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.PrintWriter;import java.util.Arrays;public class Main {public static void main(String[] args) throws IOException {BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));int n = Integer.parseInt(stdReader.readLine());String[] temps = stdReader.readLine().split(" ");int[] nums = new int[temps.length];for(int i=0;i<nums.length;i++){nums[i] = Integer.parseInt(temps[i]);}Arrays.sort(nums);if(nums.length%2!=0){System.out.println(nums[nums.length/2]);}else{System.out.println((double)(nums[nums.length/2]+nums[(nums.length/2)-1])/2);}}}