結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2017-06-20 12:33:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 185 ms / 1,000 ms |
コード長 | 450 bytes |
コンパイル時間 | 1,919 ms |
コンパイル使用メモリ | 74,476 KB |
実行使用メモリ | 43,200 KB |
最終ジャッジ日時 | 2024-06-25 00:33:48 |
合計ジャッジ時間 | 9,401 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] num = new int[N]; for(int i = 0; i < N; i++) { num[i] = sc.nextInt(); } Arrays.sort(num); double ans = 0; if(N % 2 == 0) { ans = (double)(num[N / 2] + num[N / 2 - 1]) / (double)2; } else { ans = num[N / 2]; } System.out.println(ans); } }