結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2018-06-22 00:47:47 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 207 ms / 1,000 ms |
コード長 | 457 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 74,820 KB |
実行使用メモリ | 54,916 KB |
最終ジャッジ日時 | 2024-06-25 01:47:37 |
合計ジャッジ時間 | 10,488 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import java.util.Scanner; class no275{ public static void main(String[] args) { Scanner stdIn=new Scanner(System.in); int n,i,j,t,a[]=new int[1000]; n=stdIn.nextInt(); for(i=0;i<n;i++) a[i]=stdIn.nextInt(); for(i=0;i<n-1;i++) { for(j=n-1;j>i;j--) { if(a[j-1]>a[j]) { t=a[j-1]; a[j-1]=a[j]; a[j]=t; } } } if(n%2==0) System.out.print((a[n/2-1]+a[n/2])/2.); else System.out.print(a[n/2]); } }