結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2023-09-13 22:59:21 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 212 ms / 1,000 ms |
コード長 | 675 bytes |
コンパイル時間 | 2,132 ms |
コンパイル使用メモリ | 73,996 KB |
実行使用メモリ | 55,176 KB |
最終ジャッジ日時 | 2024-07-01 07:11:07 |
合計ジャッジ時間 | 10,440 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import java.util.Scanner; class Y275{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] A=new int[n]; for(int i=0;i<n;i++){ A[i]=sc.nextInt(); } for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ if(A[i]>A[j]){ int tmp=A[i]; A[i]=A[j]; A[j]=tmp; } } } double ans; if(n%2==0){ ans=(A[n/2-1]+A[n/2])/2.0; System.out.print(ans); }else{ System.out.println(A[n/2]); } } }