結果
| 問題 | No.275 中央値を求めよ |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-24 16:56:01 |
| 言語 | Crystal (1.19.1) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| + 728µs | |
| コード長 | 566 bytes |
| 記録 | |
| コンパイル時間 | 15,840 ms |
| コンパイル使用メモリ | 374,748 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-16 23:03:30 |
| 合計ジャッジ時間 | 12,950 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
lib C
fun getchar_unlocked : Int32
end
def read_i : Int32
ans = 0
f = 1
c = C.getchar_unlocked()
while [9, 10, 11, 12, 13, 32].includes?(c)
c = C.getchar_unlocked()
end
if c == 45
f = -1
c = C.getchar_unlocked()
end
while (48 .. 57).includes?(c)
ans = (ans << 1) + (ans << 3) + (c ^ 48)
c = C.getchar_unlocked()
end
return ans * f
end
n = read_i
a = Array(Int32).new(n) {read_i}.sort
if n & 1 == 1
puts(a[n >> 1])
else
printf("%.1f\n", (a[n >> 1] + a[(n >> 1) - 1]) / 2)
end
vjudge1