結果

問題 No.275 中央値を求めよ
ユーザー osada-yum
提出日時 2024-05-03 12:13:52
言語 Fortran
(gFortran 14.2.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 656 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 32,760 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 12:06:07
合計ジャッジ時間 1,397 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

program yukicoder_746
  use, intrinsic :: iso_fortran_env
  implicit none
  integer(int32), parameter :: maxi = 1000
  integer(int32) :: n, cnts(-maxi:maxi), c
  integer(int32), allocatable :: arr(:)
  integer(int32) :: i, j
  read(input_unit, *) n
  allocate(arr(n))
  read(input_unit, *) arr(:)
  cnts(:) = 0
  do i = 1, n
     cnts(arr(i)) = cnts(arr(i)) + 1
  end do
  c = 0
  do i = -maxi, maxi
     do j = 1, cnts(i)
        c = c + 1
        arr(c) = i
     end do
  end do
  associate(half_1 => (n + 1) / 2, half_2 => (n + 2) / 2)
    write(output_unit, '(g0)') real(arr(half_1) + arr(half_2), real64) / 2
  end associate
end program yukicoder_746
0