結果

問題 No.275 中央値を求めよ
ユーザー yoza
提出日時 2016-12-11 22:39:08
言語 Vim script
(v9.1)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 606 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 12,032 KB
最終ジャッジ日時 2024-06-25 00:09:18
合計ジャッジ時間 2,697 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

function! s:output()
  let this = {'lines': []}

  function! this.append(line) abort
    call add(self.lines, a:line)
  endfunction

  function! this.build() abort
    return join(self.lines, "\n")
  endfunction

  return this
endfunction

function! s:main(input) abort
  let o = s:output()

  let a_list = map(split(a:input[1], ' '), 'str2nr(v:val)')
  call sort(a_list, 'f')
  let left = (len(a_list) - 1) / 2
  let right = len(a_list) / 2
  let r = (a_list[left] + a_list[right]) / 2.0

  call o.append(r)
  return o.build()
endfunction

let s:input = getline(1, '$')
enew
put =s:main(s:input)
2,$print
0