結果

問題 No.275 中央値を求めよ
ユーザー SuunnSuunn
提出日時 2018-12-01 19:47:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,377 bytes
コンパイル時間 3,426 ms
コンパイル使用メモリ 74,232 KB
実行使用メモリ 51,308 KB
最終ジャッジ日時 2023-09-09 06:53:25
合計ジャッジ時間 6,087 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,276 KB
testcase_01 AC 44 ms
49,416 KB
testcase_02 AC 44 ms
49,212 KB
testcase_03 WA -
testcase_04 AC 43 ms
49,292 KB
testcase_05 AC 44 ms
49,600 KB
testcase_06 AC 44 ms
49,272 KB
testcase_07 AC 46 ms
49,104 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 45 ms
49,620 KB
testcase_11 WA -
testcase_12 AC 45 ms
49,240 KB
testcase_13 WA -
testcase_14 AC 44 ms
49,112 KB
testcase_15 AC 48 ms
49,140 KB
testcase_16 AC 46 ms
49,236 KB
testcase_17 AC 47 ms
49,184 KB
testcase_18 AC 45 ms
49,244 KB
testcase_19 WA -
testcase_20 AC 46 ms
49,128 KB
testcase_21 AC 45 ms
49,076 KB
testcase_22 AC 47 ms
49,376 KB
testcase_23 WA -
testcase_24 AC 45 ms
49,396 KB
testcase_25 AC 47 ms
49,456 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 47 ms
49,244 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 45 ms
49,420 KB
testcase_38 AC 46 ms
49,412 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.Arrays;
import java.util.NoSuchElementException;

 
public class Main{

	
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		if(N%2==1){
			System.out.println(N/2);
		}else{
			System.out.println(((double)a[N/2-1]+(double)a[N/2])/2.0);
		}
	}
	
	

	
}









class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}


0